File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed
Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change 11## 题目地址(24. 两两交换链表中的节点)
2+
23https://leetcode-cn.com/problems/swap-nodes-in-pairs/
34
45## 题目描述
56
6-
77给定一个链表,两两交换其中相邻的节点,并返回交换后的链表。
88
99你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换。
1010
1111![ image.png] ( https://assets.leetcode.com/uploads/2020/10/03/swap_ex1.jpg )
1212
1313```
14-
1514示例 1:
16-
17-
1815输入:head = [1,2,3,4]
1916输出:[2,1,4,3]
20- 示例 2:
2117
18+ 示例 2:
2219输入:head = []
2320输出:[]
24- 示例 3:
2521
22+ 示例 3:
2623输入:head = [1]
2724输出:[1]
28-
2925
3026提示:
31-
3227链表中节点的数目在范围 [0, 100] 内
33280 <= Node.val <= 100
34-
3529```
3630
3731## 前置知识
@@ -70,7 +64,9 @@ https://leetcode-cn.com/problems/swap-nodes-in-pairs/
7064
7165## 代码
7266
73- * 语言支持:JS,Python3, Go, PHP
67+ - 语言支持:JS,Python3, Go, PHP
68+
69+ JS Code:
7470
7571``` js
7672/**
@@ -103,9 +99,10 @@ var swapPairs = function(head) {
10399 }
104100 return dummy .next ;
105101};
106-
107102```
108- Python3 Code:
103+
104+ Python Code:
105+
109106``` python
110107class Solution :
111108 def swapPairs (self , head : ListNode) -> ListNode:
You can’t perform that action at this time.
0 commit comments