mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-07 00:11:41 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>有一堆石头,用整数数组 <code>stones</code> 表示。其中 <code>stones[i]</code> 表示第 <code>i</code> 块石头的重量。</p>\n\n<p>每一回合,从中选出<strong>任意两块石头</strong>,然后将它们一起粉碎。假设石头的重量分别为 <code>x</code> 和 <code>y</code>,且 <code>x <= y</code>。那么粉碎的可能结果如下:</p>\n\n<ul>\n\t<li>如果 <code>x == y</code>,那么两块石头都会被完全粉碎;</li>\n\t<li>如果 <code>x != y</code>,那么重量为 <code>x</code> 的石头将会完全粉碎,而重量为 <code>y</code> 的石头新重量为 <code>y-x</code>。</li>\n</ul>\n\n<p>最后,<strong>最多只会剩下一块 </strong>石头。返回此石头 <strong>最小的可能重量 </strong>。如果没有石头剩下,就返回 <code>0</code>。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>stones = [2,7,4,1,8,1]\n<strong>输出:</strong>1\n<strong>解释:</strong>\n组合 2 和 4,得到 2,所以数组转化为 [2,7,1,8,1],\n组合 7 和 8,得到 1,所以数组转化为 [2,1,1,1],\n组合 2 和 1,得到 1,所以数组转化为 [1,1,1],\n组合 1 和 1,得到 0,所以数组转化为 [1],这就是最优值。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>stones = [31,26,33,21,40]\n<strong>输出:</strong>5\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= stones.length <= 30</code></li>\n\t<li><code>1 <= stones[i] <= 100</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 413,
|
||||
"likes": 436,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"59.5K\", \"totalSubmission\": \"89.6K\", \"totalAcceptedRaw\": 59508, \"totalSubmissionRaw\": 89646, \"acRate\": \"66.4%\"}",
|
||||
"stats": "{\"totalAccepted\": \"64.7K\", \"totalSubmission\": \"96.9K\", \"totalAcceptedRaw\": 64740, \"totalSubmissionRaw\": 96941, \"acRate\": \"66.8%\"}",
|
||||
"hints": [
|
||||
"Think of the final answer as a sum of weights with + or - sign symbols infront of each weight. Actually, all sums with 1 of each sign symbol are possible.",
|
||||
"Use dynamic programming: for every possible sum with N stones, those sums +x or -x is possible with N+1 stones, where x is the value of the newest stone. (This overcounts sums that are all positive or all negative, but those don't matter.)"
|
||||
|
Reference in New Issue
Block a user