mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
存量题库数据更新
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个下标从 <strong>0</strong> 开始、长度为 <code>n</code> 的整数数组 <code>nums</code> ,和一个整数 <code>k</code> 。</p>\n\n<p>你可以执行下述 <strong>递增</strong> 运算 <strong>任意</strong> 次(可以是 <strong>0</strong> 次):</p>\n\n<ul>\n\t<li>从范围 <code>[0, n - 1]</code> 中选择一个下标 <code>i</code> ,并将 <code>nums[i]</code> 的值加 <code>1</code> 。</li>\n</ul>\n\n<p>如果数组中任何长度 <strong>大于或等于 3</strong> 的子数组,其 <strong>最大</strong> 元素都大于或等于 <code>k</code> ,则认为数组是一个 <strong>美丽数组</strong> 。</p>\n\n<p>以整数形式返回使数组变为 <strong>美丽数组</strong> 需要执行的 <strong>最小</strong> 递增运算数。</p>\n\n<p>子数组是数组中的一个连续 <strong>非空</strong> 元素序列。</p>\n\n<p> </p>\n\n<p><strong class=\"example\">示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [2,3,0,0,2], k = 4\n<strong>输出:</strong>3\n<strong>解释:</strong>可以执行下述递增运算,使 nums 变为美丽数组:\n选择下标 i = 1 ,并且将 nums[1] 的值加 1 -> [2,4,0,0,2] 。\n选择下标 i = 4 ,并且将 nums[4] 的值加 1 -> [2,4,0,0,3] 。\n选择下标 i = 4 ,并且将 nums[4] 的值加 1 -> [2,4,0,0,4] 。\n长度大于或等于 3 的子数组为 [2,4,0], [4,0,0], [0,0,4], [2,4,0,0], [4,0,0,4], [2,4,0,0,4] 。\n在所有子数组中,最大元素都等于 k = 4 ,所以 nums 现在是美丽数组。\n可以证明无法用少于 3 次递增运算使 nums 变为美丽数组。\n因此,答案为 3 。\n</pre>\n\n<p><strong class=\"example\">示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [0,1,3,3], k = 5\n<strong>输出:</strong>2\n<strong>解释:</strong>可以执行下述递增运算,使 nums 变为美丽数组:\n选择下标 i = 2 ,并且将 nums[2] 的值加 1 -> [0,1,4,3] 。\n选择下标 i = 2 ,并且将 nums[2] 的值加 1 -> [0,1,5,3] 。\n长度大于或等于 3 的子数组为 [0,1,5]、[1,5,3]、[0,1,5,3] 。\n在所有子数组中,最大元素都等于 k = 5 ,所以 nums 现在是美丽数组。\n可以证明无法用少于 2 次递增运算使 nums 变为美丽数组。 \n因此,答案为 2 。\n</pre>\n\n<p><strong class=\"example\">示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [1,1,2], k = 1\n<strong>输出:</strong>0\n<strong>解释:</strong>在这个示例中,只有一个长度大于或等于 3 的子数组 [1,1,2] 。\n其最大元素 2 已经大于 k = 1 ,所以无需执行任何增量运算。\n因此,答案为 0 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>3 <= n == nums.length <= 10<sup>5</sup></code></li>\n\t<li><code>0 <= nums[i] <= 10<sup>9</sup></code></li>\n\t<li><code>0 <= k <= 10<sup>9</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 28,
|
||||
"likes": 32,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -149,7 +149,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"3.5K\", \"totalSubmission\": \"9.3K\", \"totalAcceptedRaw\": 3484, \"totalSubmissionRaw\": 9313, \"acRate\": \"37.4%\"}",
|
||||
"stats": "{\"totalAccepted\": \"4K\", \"totalSubmission\": \"10.4K\", \"totalAcceptedRaw\": 4046, \"totalSubmissionRaw\": 10388, \"acRate\": \"38.9%\"}",
|
||||
"hints": [
|
||||
"There needs to be at least one value among <code>3</code> consecutive values in the array that is greater than or equal to <code>k</code>.",
|
||||
"The problem can be solved using dynamic programming.",
|
||||
|
Reference in New Issue
Block a user