1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-07 00:11:41 +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>stones</code> 表示。其中&nbsp;<code>stones[i]</code> 表示第 <code>i</code> 块石头的重量。</p>\n\n<p>每一回合,从中选出<strong>任意两块石头</strong>,然后将它们一起粉碎。假设石头的重量分别为&nbsp;<code>x</code> 和&nbsp;<code>y</code>,且&nbsp;<code>x &lt;= y</code>。那么粉碎的可能结果如下:</p>\n\n<ul>\n\t<li>如果&nbsp;<code>x == y</code>,那么两块石头都会被完全粉碎;</li>\n\t<li>如果&nbsp;<code>x != y</code>,那么重量为&nbsp;<code>x</code>&nbsp;的石头将会完全粉碎,而重量为&nbsp;<code>y</code>&nbsp;的石头新重量为&nbsp;<code>y-x</code>。</li>\n</ul>\n\n<p>最后,<strong>最多只会剩下一块 </strong>石头。返回此石头 <strong>最小的可能重量 </strong>。如果没有石头剩下,就返回 <code>0</code>。</p>\n\n<p>&nbsp;</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>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= stones.length &lt;= 30</code></li>\n\t<li><code>1 &lt;= stones[i] &lt;= 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.)"