1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-02 22:13:28 +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>有一个甜甜圈商店,每批次都烤 <code>batchSize</code> 个甜甜圈。这个店铺有个规则,就是在烤一批新的甜甜圈时,之前 <strong>所有</strong> 甜甜圈都必须已经全部销售完毕。给你一个整数 <code>batchSize</code> 和一个整数数组 <code>groups</code> ,数组中的每个整数都代表一批前来购买甜甜圈的顾客,其中 <code>groups[i]</code> 表示这一批顾客的人数。每一位顾客都恰好只要一个甜甜圈。</p>\n\n<p>当有一批顾客来到商店时,他们所有人都必须在下一批顾客来之前购买完甜甜圈。如果一批顾客中第一位顾客得到的甜甜圈不是上一组剩下的,那么这一组人都会很开心。</p>\n\n<p>你可以随意安排每批顾客到来的顺序。请你返回在此前提下,<strong>最多</strong> 有多少组人会感到开心。</p>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<b>输入:</b>batchSize = 3, groups = [1,2,3,4,5,6]\n<b>输出:</b>4\n<b>解释:</b>你可以将这些批次的顾客顺序安排为 [6,2,4,5,1,3] 。那么第 1246 组都会感到开心。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<b>输入:</b>batchSize = 4, groups = [1,3,2,5,2,2,1,6]\n<b>输出:</b>4\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= batchSize <= 9</code></li>\n\t<li><code>1 <= groups.length <= 30</code></li>\n\t<li><code>1 <= groups[i] <= 10<sup>9</sup></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 30,
"likes": 31,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -161,7 +161,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"2K\", \"totalSubmission\": \"6.5K\", \"totalAcceptedRaw\": 1962, \"totalSubmissionRaw\": 6526, \"acRate\": \"30.1%\"}",
"stats": "{\"totalAccepted\": \"2K\", \"totalSubmission\": \"6.7K\", \"totalAcceptedRaw\": 2021, \"totalSubmissionRaw\": 6671, \"acRate\": \"30.3%\"}",
"hints": [
"The maximum number of happy groups is the maximum number of partitions you can split the groups into such that the sum of group sizes in each partition is 0 mod batchSize. At most one partition is allowed to have a different remainder (the first group will get fresh donuts anyway).",
"Suppose you have an array freq of length k where freq[i] = number of groups of size i mod batchSize. How can you utilize this in a dp solution?",