1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-22 05:26:46 +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>nums</code> 和一个整数 <code>k</code> 。 <code>nums</code> 仅包含 <code>0</code> 和 <code>1</code> 。每一次移动,你可以选择 <strong>相邻</strong> 两个数字并将它们交换。</p>\n\n<p>请你返回使 <code>nums</code> 中包含 <code>k</code> 个 <strong>连续 </strong><code>1</code> 的 <strong>最少</strong> 交换次数。</p>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<pre><b>输入:</b>nums = [1,0,0,1,0,1], k = 2\n<b>输出:</b>1\n<b>解释:</b>在第一次操作时nums 可以变成 [1,0,0,0,<strong>1</strong>,<strong>1</strong>] 得到连续两个 1 。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre><b>输入:</b>nums = [1,0,0,0,0,0,1,1], k = 3\n<b>输出:</b>5\n<b>解释:</b>通过 5 次操作,最左边的 1 可以移到右边直到 nums 变为 [0,0,0,0,0,<strong>1</strong>,<strong>1</strong>,<strong>1</strong>] 。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre><b>输入:</b>nums = [1,1,0,1], k = 2\n<b>输出:</b>0\n<b>解释:</b>nums 已经有连续 2 个 1 了。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>\n\t<li><code>nums[i]</code> 要么是 <code>0</code> ,要么是 <code>1</code> 。</li>\n\t<li><code>1 &lt;= k &lt;= sum(nums)</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 43,
"likes": 45,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -155,7 +155,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"1.6K\", \"totalSubmission\": \"4.3K\", \"totalAcceptedRaw\": 1648, \"totalSubmissionRaw\": 4300, \"acRate\": \"38.3%\"}",
"stats": "{\"totalAccepted\": \"1.8K\", \"totalSubmission\": \"4.4K\", \"totalAcceptedRaw\": 1750, \"totalSubmissionRaw\": 4445, \"acRate\": \"39.4%\"}",
"hints": [
"Choose k 1s and determine how many steps are required to move them into 1 group.",
"Maintain a sliding window of k 1s, and maintain the steps required to group them.",