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>0</strong> 开始的数组 <code>nums</code> ,该数组由 <code>n</code> 个正整数组成。</p>\n\n<p>如果满足下述条件,则数组 <code>nums</code> 是一个 <strong>交替数组</strong> :</p>\n\n<ul>\n\t<li><code>nums[i - 2] == nums[i]</code> ,其中 <code>2 <= i <= n - 1</code> 。</li>\n\t<li><code>nums[i - 1] != nums[i]</code> ,其中 <code>1 <= i <= n - 1</code> 。</li>\n</ul>\n\n<p>在一步 <strong>操作</strong> 中,你可以选择下标 <code>i</code> 并将 <code>nums[i]</code> <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>\n<strong>输入:</strong>nums = [3,1,3,2,4,3]\n<strong>输出:</strong>3\n<strong>解释:</strong>\n使数组变成交替数组的方法之一是将该数组转换为 [3,1,3,<em><strong>1</strong></em>,<em><strong>3</strong></em>,<em><strong>1</strong></em>] 。\n在这种情况下,操作数为 3 。\n可以证明,操作数少于 3 的情况下,无法使数组变成交替数组。</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [1,2,2,2,2]\n<strong>输出:</strong>2\n<strong>解释:</strong>\n使数组变成交替数组的方法之一是将该数组转换为 [1,2,<em><strong>1</strong></em>,2,<em><strong>1</strong></em>].\n在这种情况下,操作数为 2 。\n注意,数组不能转换成 [<em><strong>2</strong></em>,2,2,2,2] 。因为在这种情况下,nums[0] == nums[1],不满足交替数组的条件。\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>5</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 25,
|
||||
"likes": 27,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -155,7 +155,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"6.2K\", \"totalSubmission\": \"21.3K\", \"totalAcceptedRaw\": 6168, \"totalSubmissionRaw\": 21303, \"acRate\": \"29.0%\"}",
|
||||
"stats": "{\"totalAccepted\": \"6.5K\", \"totalSubmission\": \"22.3K\", \"totalAcceptedRaw\": 6523, \"totalSubmissionRaw\": 22349, \"acRate\": \"29.2%\"}",
|
||||
"hints": [
|
||||
"Count the frequency of each element in odd positions in the array. Do the same for elements in even positions.",
|
||||
"To minimize the number of operations we need to maximize the number of elements we keep from the original array.",
|
||||
|
Reference in New Issue
Block a user