1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-21 21:16:45 +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>head</code> 和一个整数 <code>k</code> 。</p>\n\n<p><strong>交换</strong> 链表正数第 <code>k</code> 个节点和倒数第 <code>k</code> 个节点的值后,返回链表的头节点(链表 <strong>从 1 开始索引</strong>)。</p>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2021/01/10/linked1.jpg\" style=\"width: 722px; height: 202px;\" />\n<pre>\n<strong>输入:</strong>head = [1,2,3,4,5], k = 2\n<strong>输出:</strong>[1,4,3,2,5]\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>head = [7,9,6,6,7,8,3,0,9,5], k = 5\n<strong>输出:</strong>[7,9,6,6,8,7,3,0,9,5]\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<strong>输入:</strong>head = [1], k = 1\n<strong>输出:</strong>[1]\n</pre>\n\n<p><strong>示例 4</strong></p>\n\n<pre>\n<strong>输入:</strong>head = [1,2], k = 1\n<strong>输出:</strong>[2,1]\n</pre>\n\n<p><strong>示例 5</strong></p>\n\n<pre>\n<strong>输入:</strong>head = [1,2,3], k = 2\n<strong>输出:</strong>[1,2,3]\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li>链表中节点的数目是 <code>n</code></li>\n\t<li><code>1 <= k <= n <= 10<sup>5</sup></code></li>\n\t<li><code>0 <= Node.val <= 100</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 47,
"likes": 52,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -143,7 +143,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"13.9K\", \"totalSubmission\": \"21.6K\", \"totalAcceptedRaw\": 13896, \"totalSubmissionRaw\": 21646, \"acRate\": \"64.2%\"}",
"stats": "{\"totalAccepted\": \"14.5K\", \"totalSubmission\": \"22.7K\", \"totalAcceptedRaw\": 14474, \"totalSubmissionRaw\": 22657, \"acRate\": \"63.9%\"}",
"hints": [
"We can transform the linked list to an array this should ease things up",
"After transforming the linked list to an array it becomes as easy as swapping two integers in an array then rebuilding the linked list"