mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-02 14:12:17 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个 <strong>正</strong> 整数数组 <code>beans</code> ,其中每个整数表示一个袋子里装的魔法豆的数目。</p>\n\n<p>请你从每个袋子中 <strong>拿出</strong> 一些豆子(也可以<strong> 不拿出</strong>),使得剩下的 <strong>非空</strong> 袋子中(即 <strong>至少</strong> 还有 <strong>一颗</strong> 魔法豆的袋子)魔法豆的数目 <strong>相等</strong> 。一旦魔法豆从袋子中取出,你不能将它放到任何其他的袋子中。</p>\n\n<p>请你返回你需要拿出魔法豆的 <strong>最少数目</strong>。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre><b>输入:</b>beans = [4,<em><strong>1</strong></em>,6,5]\n<b>输出:</b>4\n<b>解释:</b>\n- 我们从有 1 个魔法豆的袋子中拿出 1 颗魔法豆。\n 剩下袋子中魔法豆的数目为:[4,<em><b>0</b></em>,6,5]\n- 然后我们从有 6 个魔法豆的袋子中拿出 2 个魔法豆。\n 剩下袋子中魔法豆的数目为:[4,0,<em><strong>4</strong></em>,5]\n- 然后我们从有 5 个魔法豆的袋子中拿出 1 个魔法豆。\n 剩下袋子中魔法豆的数目为:[4,0,4,<em><b>4</b></em>]\n总共拿出了 1 + 2 + 1 = 4 个魔法豆,剩下非空袋子中魔法豆的数目相等。\n没有比取出 4 个魔法豆更少的方案。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre><b>输入:</b>beans = [<em><strong>2</strong></em>,10,<em><strong>3</strong></em>,<em><strong>2</strong></em>]\n<b>输出:</b>7\n<strong>解释:</strong>\n- 我们从有 2 个魔法豆的其中一个袋子中拿出 2 个魔法豆。\n 剩下袋子中魔法豆的数目为:[<em><strong>0</strong></em>,10,3,2]\n- 然后我们从另一个有 2 个魔法豆的袋子中拿出 2 个魔法豆。\n 剩下袋子中魔法豆的数目为:[0,10,3,<em><strong>0</strong></em>]\n- 然后我们从有 3 个魔法豆的袋子中拿出 3 个魔法豆。\n 剩下袋子中魔法豆的数目为:[0,10,<em><strong>0</strong></em>,0]\n总共拿出了 2 + 2 + 3 = 7 个魔法豆,剩下非空袋子中魔法豆的数目相等。\n没有比取出 7 个魔法豆更少的方案。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= beans.length <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= beans[i] <= 10<sup>5</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 26,
|
||||
"likes": 30,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -149,7 +149,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"6.7K\", \"totalSubmission\": \"17.2K\", \"totalAcceptedRaw\": 6742, \"totalSubmissionRaw\": 17202, \"acRate\": \"39.2%\"}",
|
||||
"stats": "{\"totalAccepted\": \"7K\", \"totalSubmission\": \"18.1K\", \"totalAcceptedRaw\": 7047, \"totalSubmissionRaw\": 18051, \"acRate\": \"39.0%\"}",
|
||||
"hints": [
|
||||
"Notice that if we choose to make x bags of beans empty, we should choose the x bags with the least amount of beans.",
|
||||
"Notice that if the minimum number of beans in a non-empty bag is m, then the best way to make all bags have an equal amount of beans is to reduce all the bags to have m beans.",
|
||||
|
Reference in New Issue
Block a user