mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-26 07:18:56 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个链表的头节点 <code>head</code> 。</p>\n\n<p>链表中的节点 <strong>按顺序</strong> 划分成若干 <strong>非空</strong> 组,这些非空组的长度构成一个自然数序列(<code>1, 2, 3, 4, ...</code>)。一个组的 <strong>长度</strong> 就是组中分配到的节点数目。换句话说:</p>\n\n<ul>\n\t<li>节点 <code>1</code> 分配给第一组</li>\n\t<li>节点 <code>2</code> 和 <code>3</code> 分配给第二组</li>\n\t<li>节点 <code>4</code>、<code>5</code> 和 <code>6</code> 分配给第三组,以此类推</li>\n</ul>\n\n<p>注意,最后一组的长度可能小于或者等于 <code>1 + 倒数第二组的长度</code> 。</p>\n\n<p><strong>反转</strong> 每个 <strong>偶数</strong> 长度组中的节点,并返回修改后链表的头节点 <code>head</code> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/10/25/eg1.png\" style=\"width: 699px; height: 124px;\" /></p>\n\n<pre>\n<strong>输入:</strong>head = [5,2,6,3,9,1,7,3,8,4]\n<strong>输出:</strong>[5,6,2,3,9,1,4,8,3,7]\n<strong>解释:</strong>\n- 第一组长度为 1 ,奇数,没有发生反转。\n- 第二组长度为 2 ,偶数,节点反转。\n- 第三组长度为 3 ,奇数,没有发生反转。\n- 最后一组长度为 4 ,偶数,节点反转。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/10/25/eg2.png\" style=\"width: 284px; height: 114px;\" /></p>\n\n<pre>\n<strong>输入:</strong>head = [1,1,0,6]\n<strong>输出:</strong>[1,0,1,6]\n<strong>解释:</strong>\n- 第一组长度为 1 ,没有发生反转。\n- 第二组长度为 2 ,节点反转。\n- 最后一组长度为 1 ,没有发生反转。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/10/28/eg3.png\" style=\"width: 139px; height: 114px;\" /></p>\n\n<pre>\n<strong>输入:</strong>head = [2,1]\n<strong>输出:</strong>[2,1]\n<strong>解释:</strong>\n- 第一组长度为 1 ,没有发生反转。\n- 最后一组长度为 1 ,没有发生反转。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li>链表中节点数目范围是 <code>[1, 10<sup>5</sup>]</code></li>\n\t<li><code>0 <= Node.val <= 10<sup>5</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 13,
|
||||
"likes": 15,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -137,7 +137,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"4.6K\", \"totalSubmission\": \"10.7K\", \"totalAcceptedRaw\": 4603, \"totalSubmissionRaw\": 10730, \"acRate\": \"42.9%\"}",
|
||||
"stats": "{\"totalAccepted\": \"4.8K\", \"totalSubmission\": \"11K\", \"totalAcceptedRaw\": 4752, \"totalSubmissionRaw\": 11025, \"acRate\": \"43.1%\"}",
|
||||
"hints": [
|
||||
"Consider the list structure ...A → (B → ... → C) → D..., where the nodes between B and C (inclusive) form a group, A is the last node of the previous group, and D is the first node of the next group. How can you utilize this structure?",
|
||||
"Suppose you have B → ... → C reversed (because it was of even length) so that it is now C → ... → B. What references do you need to fix so that the transitions between the previous, current, and next groups are correct?",
|
||||
|
||||
Reference in New Issue
Block a user