mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-21 13:06:47 +08:00
update
This commit is contained in:
@@ -9,10 +9,10 @@
|
||||
"titleSlug": "reverse-nodes-in-k-group",
|
||||
"content": "<p>Given the <code>head</code> of a linked list, reverse the nodes of the list <code>k</code> at a time, and return <em>the modified list</em>.</p>\n\n<p><code>k</code> is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of <code>k</code> then left-out nodes, in the end, should remain as it is.</p>\n\n<p>You may not alter the values in the list's nodes, only nodes themselves may be changed.</p>\n\n<p> </p>\n<p><strong>Example 1:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2020/10/03/reverse_ex1.jpg\" style=\"width: 542px; height: 222px;\" />\n<pre>\n<strong>Input:</strong> head = [1,2,3,4,5], k = 2\n<strong>Output:</strong> [2,1,4,3,5]\n</pre>\n\n<p><strong>Example 2:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2020/10/03/reverse_ex2.jpg\" style=\"width: 542px; height: 222px;\" />\n<pre>\n<strong>Input:</strong> head = [1,2,3,4,5], k = 3\n<strong>Output:</strong> [3,2,1,4,5]\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li>The number of nodes in the list is <code>n</code>.</li>\n\t<li><code>1 <= k <= n <= 5000</code></li>\n\t<li><code>0 <= Node.val <= 1000</code></li>\n</ul>\n\n<p> </p>\n<p><strong>Follow-up:</strong> Can you solve the problem in <code>O(1)</code> extra memory space?</p>\n",
|
||||
"translatedTitle": "K 个一组翻转链表",
|
||||
"translatedContent": "<p>给你一个链表,每 <em>k </em>个节点一组进行翻转,请你返回翻转后的链表。</p>\n\n<p><em>k </em>是一个正整数,它的值小于或等于链表的长度。</p>\n\n<p>如果节点总数不是 <em>k </em>的整数倍,那么请将最后剩余的节点保持原有顺序。</p>\n\n<p><strong>进阶:</strong></p>\n\n<ul>\n\t<li>你可以设计一个只使用常数额外空间的算法来解决此问题吗?</li>\n\t<li><strong>你不能只是单纯的改变节点内部的值</strong>,而是需要实际进行节点交换。</li>\n</ul>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2020/10/03/reverse_ex1.jpg\" style=\"width: 542px; height: 222px;\" />\n<pre>\n<strong>输入:</strong>head = [1,2,3,4,5], k = 2\n<strong>输出:</strong>[2,1,4,3,5]\n</pre>\n\n<p><strong>示例 2:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2020/10/03/reverse_ex2.jpg\" style=\"width: 542px; height: 222px;\" />\n<pre>\n<strong>输入:</strong>head = [1,2,3,4,5], k = 3\n<strong>输出:</strong>[3,2,1,4,5]\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong>head = [1,2,3,4,5], k = 1\n<strong>输出:</strong>[1,2,3,4,5]\n</pre>\n\n<p><strong>示例 4:</strong></p>\n\n<pre>\n<strong>输入:</strong>head = [1], k = 1\n<strong>输出:</strong>[1]\n</pre>\n\n<ul>\n</ul>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li>列表中节点的数量在范围 <code>sz</code> 内</li>\n\t<li><code>1 <= sz <= 5000</code></li>\n\t<li><code>0 <= Node.val <= 1000</code></li>\n\t<li><code>1 <= k <= sz</code></li>\n</ul>\n",
|
||||
"translatedContent": "<p>给你链表的头节点 <code>head</code> ,每 <code>k</code><em> </em>个节点一组进行翻转,请你返回修改后的链表。</p>\n\n<p><code>k</code> 是一个正整数,它的值小于或等于链表的长度。如果节点总数不是 <code>k</code><em> </em>的整数倍,那么请将最后剩余的节点保持原有顺序。</p>\n\n<p>你不能只是单纯的改变节点内部的值,而是需要实际进行节点交换。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2020/10/03/reverse_ex1.jpg\" style=\"width: 542px; height: 222px;\" />\n<pre>\n<strong>输入:</strong>head = [1,2,3,4,5], k = 2\n<strong>输出:</strong>[2,1,4,3,5]\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2020/10/03/reverse_ex2.jpg\" style=\"width: 542px; height: 222px;\" /></p>\n\n<pre>\n<strong>输入:</strong>head = [1,2,3,4,5], k = 3\n<strong>输出:</strong>[3,2,1,4,5]\n</pre>\n\n<p> </p>\n<strong>提示:</strong>\n\n<ul>\n\t<li>链表中的节点数目为 <code>n</code></li>\n\t<li><code>1 <= k <= n <= 5000</code></li>\n\t<li><code>0 <= Node.val <= 1000</code></li>\n</ul>\n\n<p> </p>\n\n<p><strong>进阶:</strong>你可以设计一个只用 <code>O(1)</code> 额外内存空间的算法解决此问题吗?</p>\n\n<ul>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 1558,
|
||||
"likes": 1597,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Swap Nodes in Pairs\", \"titleSlug\": \"swap-nodes-in-pairs\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u4e24\\u4e24\\u4ea4\\u6362\\u94fe\\u8868\\u4e2d\\u7684\\u8282\\u70b9\"}]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"303.6K\", \"totalSubmission\": \"456.6K\", \"totalAcceptedRaw\": 303586, \"totalSubmissionRaw\": 456621, \"acRate\": \"66.5%\"}",
|
||||
"stats": "{\"totalAccepted\": \"326.3K\", \"totalSubmission\": \"486.5K\", \"totalAcceptedRaw\": 326321, \"totalSubmissionRaw\": 486479, \"acRate\": \"67.1%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
|
Reference in New Issue
Block a user