1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-22 13:36:46 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你一个正整数数组&nbsp;<code>arr</code>,考虑所有满足以下条件的二叉树:</p>\n\n<ul>\n\t<li>每个节点都有 0 个或是 2 个子节点。</li>\n\t<li>数组&nbsp;<code>arr</code>&nbsp;中的值与树的中序遍历中每个叶节点的值一一对应。(知识回顾:如果一个节点有 0 个子节点,那么该节点为叶节点。)</li>\n\t<li>每个非叶节点的值等于其左子树和右子树中叶节点的最大值的乘积。</li>\n</ul>\n\n<p>在所有这样的二叉树中,返回每个非叶节点的值的最小可能总和。这个和的值是一个&nbsp;32 位整数。</p>\n\n<p>&nbsp;</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>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>2 &lt;= arr.length &lt;= 40</code></li>\n\t<li><code>1 &lt;= arr[i] &lt;= 15</code></li>\n\t<li>答案保证是一个 32 位带符号整数,即小于&nbsp;<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)."