mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-22 13:36:46 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个正整数数组 <code>arr</code>,考虑所有满足以下条件的二叉树:</p>\n\n<ul>\n\t<li>每个节点都有 0 个或是 2 个子节点。</li>\n\t<li>数组 <code>arr</code> 中的值与树的中序遍历中每个叶节点的值一一对应。(知识回顾:如果一个节点有 0 个子节点,那么该节点为叶节点。)</li>\n\t<li>每个非叶节点的值等于其左子树和右子树中叶节点的最大值的乘积。</li>\n</ul>\n\n<p>在所有这样的二叉树中,返回每个非叶节点的值的最小可能总和。这个和的值是一个 32 位整数。</p>\n\n<p> </p>\n\n<p><strong>示例:</strong></p>\n\n<pre><strong>输入:</strong>arr = [6,2,4]\n<strong>输出:</strong>32\n<strong>解释:</strong>\n有两种可能的树,第一种的非叶节点的总和为 36,第二种非叶节点的总和为 32。\n\n 24 24\n / \\ / \\\n 12 4 6 8\n / \\ / \\\n6 2 2 4</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>2 <= arr.length <= 40</code></li>\n\t<li><code>1 <= arr[i] <= 15</code></li>\n\t<li>答案保证是一个 32 位带符号整数,即小于 <code>2^31</code>。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 223,
|
||||
"likes": 225,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -155,7 +155,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"6.9K\", \"totalSubmission\": \"10.9K\", \"totalAcceptedRaw\": 6930, \"totalSubmissionRaw\": 10892, \"acRate\": \"63.6%\"}",
|
||||
"stats": "{\"totalAccepted\": \"7.1K\", \"totalSubmission\": \"11.1K\", \"totalAcceptedRaw\": 7096, \"totalSubmissionRaw\": 11123, \"acRate\": \"63.8%\"}",
|
||||
"hints": [
|
||||
"Do a DP, where dp(i, j) is the answer for the subarray arr[i]..arr[j].",
|
||||
"For each possible way to partition the subarray i <= k < j, the answer is max(arr[i]..arr[k]) * max(arr[k+1]..arr[j]) + dp(i, k) + dp(k+1, j)."
|
||||
|
Reference in New Issue
Block a user