mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-12-17 17:52:34 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个整数数组 <code>nums</code> 。每一次操作中,你可以将 <code>nums</code> 中 <strong>任意</strong> 一个元素替换成 <strong>任意 </strong>整数。</p>\n\n<p>如果 <code>nums</code> 满足以下条件,那么它是 <strong>连续的</strong> :</p>\n\n<ul>\n\t<li><code>nums</code> 中所有元素都是 <b>互不相同</b> 的。</li>\n\t<li><code>nums</code> 中 <strong>最大</strong> 元素与 <strong>最小</strong> 元素的差等于 <code>nums.length - 1</code> 。</li>\n</ul>\n\n<p>比方说,<code>nums = [4, 2, 5, 3]</code> 是 <strong>连续的</strong> ,但是 <code>nums = [1, 2, 3, 5, 6]</code> <strong>不是连续的</strong> 。</p>\n\n<p>请你返回使 <code>nums</code> <strong>连续</strong> 的 <strong>最少</strong> 操作次数。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre><b>输入:</b>nums = [4,2,5,3]\n<b>输出:</b>0\n<b>解释:</b>nums 已经是连续的了。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre><b>输入:</b>nums = [1,2,3,5,6]\n<b>输出:</b>1\n<b>解释:</b>一个可能的解是将最后一个元素变为 4 。\n结果数组为 [1,2,3,5,4] ,是连续数组。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre><b>输入:</b>nums = [1,10,100,1000]\n<b>输出:</b>3\n<b>解释:</b>一个可能的解是:\n- 将第二个元素变为 2 。\n- 将第三个元素变为 3 。\n- 将第四个元素变为 4 。\n结果数组为 [1,2,3,4] ,是连续数组。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= nums[i] <= 10<sup>9</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 10,
|
||||
"likes": 12,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"1.8K\", \"totalSubmission\": \"4.4K\", \"totalAcceptedRaw\": 1822, \"totalSubmissionRaw\": 4427, \"acRate\": \"41.2%\"}",
|
||||
"stats": "{\"totalAccepted\": \"1.9K\", \"totalSubmission\": \"4.5K\", \"totalAcceptedRaw\": 1875, \"totalSubmissionRaw\": 4539, \"acRate\": \"41.3%\"}",
|
||||
"hints": [
|
||||
"Sort the array.",
|
||||
"For every index do a binary search to get the possible right end of the window and calculate the possible answer."
|
||||
|
||||
Reference in New Issue
Block a user