Skip to content

Commit 4837f28

Browse files
committed
Update 24.swapNodesInPairs.md
1 parent 1d03ab9 commit 4837f28

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

problems/24.swapNodesInPairs.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,31 @@
11
## 题目地址(24. 两两交换链表中的节点)
2+
23
https://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] 内
3328
0 <= 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
110107
class Solution:
111108
def swapPairs(self, head: ListNode) -> ListNode:

0 commit comments

Comments
 (0)