1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-04 23: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>给你一个整数数组 <code>bloomDay</code>,以及两个整数 <code>m</code> 和 <code>k</code> 。</p>\n\n<p>现需要制作 <code>m</code> 束花。制作花束时,需要使用花园中 <strong>相邻的 <code>k</code> 朵花</strong> 。</p>\n\n<p>花园中有 <code>n</code> 朵花,第 <code>i</code> 朵花会在 <code>bloomDay[i]</code> 时盛开,<strong>恰好</strong> 可以用于 <strong>一束</strong> 花中。</p>\n\n<p>请你返回从花园中摘 <code>m</code> 束花需要等待的最少的天数。如果不能摘到 <code>m</code> 束花则返回 <strong>-1</strong> 。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre><strong>输入:</strong>bloomDay = [1,10,3,10,2], m = 3, k = 1\n<strong>输出:</strong>3\n<strong>解释:</strong>让我们一起观察这三天的花开过程x 表示花开,而 _ 表示花还未开。\n现在需要制作 3 束花,每束只需要 1 朵。\n1 天后:[x, _, _, _, _] // 只能制作 1 束花\n2 天后:[x, _, _, _, x] // 只能制作 2 束花\n3 天后:[x, _, x, _, x] // 可以制作 3 束花,答案为 3\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre><strong>输入:</strong>bloomDay = [1,10,3,10,2], m = 3, k = 2\n<strong>输出:</strong>-1\n<strong>解释:</strong>要制作 3 束花,每束需要 2 朵花,也就是一共需要 6 朵花。而花园中只有 5 朵花,无法满足制作要求,返回 -1 。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre><strong>输入:</strong>bloomDay = [7,7,7,7,12,7,7], m = 2, k = 3\n<strong>输出:</strong>12\n<strong>解释:</strong>要制作 2 束花,每束需要 3 朵。\n花园在 7 天后和 12 天后的情况如下:\n7 天后:[x, x, x, x, _, x, x]\n可以用前 3 朵盛开的花制作第一束花。但不能使用后 3 朵盛开的花,因为它们不相邻。\n12 天后:[x, x, x, x, x, x, x]\n显然我们可以用不同的方式制作两束花。\n</pre>\n\n<p><strong>示例 4</strong></p>\n\n<pre><strong>输入:</strong>bloomDay = [1000000000,1000000000], m = 1, k = 1\n<strong>输出:</strong>1000000000\n<strong>解释:</strong>需要等 1000000000 天才能采到花来制作花束\n</pre>\n\n<p><strong>示例 5</strong></p>\n\n<pre><strong>输入:</strong>bloomDay = [1,10,2,9,3,8,4,7,5,6], m = 4, k = 2\n<strong>输出:</strong>9\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>bloomDay.length == n</code></li>\n\t<li><code>1 &lt;= n &lt;= 10^5</code></li>\n\t<li><code>1 &lt;= bloomDay[i] &lt;= 10^9</code></li>\n\t<li><code>1 &lt;= m &lt;= 10^6</code></li>\n\t<li><code>1 &lt;= k &lt;= n</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 235,
"likes": 241,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -143,7 +143,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"33.2K\", \"totalSubmission\": \"56.4K\", \"totalAcceptedRaw\": 33160, \"totalSubmissionRaw\": 56447, \"acRate\": \"58.7%\"}",
"stats": "{\"totalAccepted\": \"33.9K\", \"totalSubmission\": \"57.6K\", \"totalAcceptedRaw\": 33945, \"totalSubmissionRaw\": 57616, \"acRate\": \"58.9%\"}",
"hints": [
"If we can make m or more bouquets at day x, then we can still make m or more bouquets at any day y > x.",
"We can check easily if we can make enough bouquets at day x if we can get group adjacent flowers at day x."