Skip to content

Commit 7ea0fad

Browse files
committed
modify some words
1 parent 92bc6c1 commit 7ea0fad

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

en/linked_list/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Linked List
22

3-
This section includes common operations on linked list, such as deletion, insertion, and combination.
3+
This section includes common operations on linked list, such as deletion, insertion, and merging.
44

55
Frequently made mistakes:
66

en/linked_list/reverse_linked_list.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Question
44

5-
- leetcode: [Reverse Linked List | LeetCode OJ](https://leetcode.com/problems/reverse-linked-list/)
5+
- leetcode: [(206) Reverse Linked List | LeetCode OJ](https://leetcode.com/problems/reverse-linked-list/)
66
- lintcode: [(35) Reverse Linked List](http://www.lintcode.com/en/problem/reverse-linked-list/)
77

88
```
@@ -19,7 +19,7 @@ Reverse it in-place and in one-pass
1919

2020
It would be much easier to reverse an array than a linked list, since array supports random access with index, while singly linked list can ONLY be operated through its head node. So an approach without index is required.
2121

22-
Think about how can '1->2->3' become '3->2->1'. Starting from '1', we should turn '1->2' into '2->1', then '2->3' into '3->2', and so on. The key is how to swap two adjacent nodes.
22+
Think about how '1->2->3' can become '3->2->1'. Starting from '1', we should turn '1->2' into '2->1', then '2->3' into '3->2', and so on. The key is how to swap two adjacent nodes.
2323

2424
```
2525
temp = head -> next;
@@ -128,17 +128,17 @@ Already covered in the solution part. One more word, the assignment of `prev` is
128128

129129
### Complexity
130130

131-
Traversing the linked list, so the time complexity is $$O(n)$$. $$O(1)$$ auxiliary space complexity.
131+
Traversing the linked list leads to ***O(n)*** time complexity, and auxiliary space complexity is ***O(1)***.
132132

133133
## Solution2 - Recursively
134134

135135
Three cases when the recursion ceases:
136136

137137
1. If given linked list is null, just return.
138138
2. If given linked list has only one node, return that node.
139-
3. If given linked list has at least two nodes, pick out the head node and regard the following nodes as a whole entity, swap them, then recurse that entity.
139+
3. If given linked list has at least two nodes, pick out the head node and regard the following nodes as a sub-linked-list, swap them, then recurse that sub-linked-list.
140140

141-
Be careful when swapping the head node (refer as `Node0`) and head of the following nodes entity (refer as 'Node1' ): First, swap `Node0` and `Node1`; Second, assign `null` to `Node0`'s next (or it would fall into infinite loop, and tail of result list won't point to `null`).
141+
Be careful when swapping the head node (refer as `nodeY`) and head of the sub-linked-list (refer as 'nodeX' ): First, swap `nodeY` and `nodeX`; Second, assign `null` to `nodeY->next` (or it would fall into infinite loop, and tail of result list won't point to `null`).
142142

143143
### Python
144144

-722 Bytes
Loading

0 commit comments

Comments
 (0)