You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## LeetCode description of "206. Reverse Linked List"
8
5
Given the `head` of a singly linked list, reverse the list, and return _the reversed list_.
9
6
10
7
### [Example 1]
@@ -31,13 +28,11 @@ Given the `head` of a singly linked list, reverse the list, and return _the reve
31
28
-`-5000 <= Node.val <= 5000`
32
29
33
30
## Intuition
34
-
[中文题解](#中文题解)
35
-
36
31
1. To solve this problem, we only need to define **two** variables: `current` and `previous`.
37
32
2.`current.next = previous` is the inversion.
38
33
3. The loop condition should be `while (current != null)` instead of `while (current.next != null)`, because the operation to be performed is `current.next = previous`.
39
34
40
-
## Steps to the Solution
35
+
## Steps
41
36
1. Traverse all nodes.
42
37
```javascript
43
38
previous =null
@@ -284,55 +279,3 @@ end
284
279
```
285
280
// Welcome to create a PR to complete the code of this language, thanks!
Given the `head` of a singly linked list, reverse the list, and return _the reversed list_.
4
+
## 力扣“206. 反转链表”问题描述
5
+
给你单链表的头节点 `head` ,请你反转链表,并返回反转后的链表。
9
6
10
-
### [Example 1]
7
+
### [示例 1]
11
8

12
9
13
-
**Input**: `head = [1,2,3,4,5]`
10
+
**输入**: `head = [1,2,3,4,5]`
14
11
15
-
**Output**: `[5,4,3,2,1]`
12
+
**输出**: `[5,4,3,2,1]`
16
13
17
-
### [Example 2]
14
+
### [示例 2]
18
15

19
16
20
-
**Input**: `[1,2]`
17
+
**输入**: `[1,2]`
21
18
22
-
**Output**: `[2,1]`
19
+
**输出**: `[2,1]`
23
20
24
-
### [Example 3]
25
-
**Input**: `[]`
21
+
### [示例 3]
22
+
**输入**: `[]`
26
23
27
-
**Output**: `[]`
24
+
**输出**: `[]`
28
25
29
-
### [Constraints]
30
-
-The number of nodes in the list is the range `[0, 5000]`.
26
+
### [约束]
27
+
-链表中节点的数目范围是 `[0, 5000]`
31
28
-`-5000 <= Node.val <= 5000`
32
29
33
-
## Intuition
34
-
[中文题解](#中文题解)
35
-
36
-
1. To solve this problem, we only need to define **two** variables: `current` and `previous`.
37
-
2.`current.next = previous` is the inversion.
38
-
3. The loop condition should be `while (current != null)` instead of `while (current.next != null)`, because the operation to be performed is `current.next = previous`.
0 commit comments