We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e0da76d commit 53edba1Copy full SHA for 53edba1
LinkedList/ReverseALinkList.cpp
@@ -30,14 +30,20 @@ class Solution {
30
// recursively reverse the rest of the list
31
// and then connect the reversed list to the head
32
// of the original list
33
- ListNode *previous = reverseList(head->next);
+ ListNode *previous = reverseListR(head->next);
34
// example:
35
- // head->next->next
36
- // ___⬇____
+ // head->next->next = head
+ // ____⬇___
37
// ⬇ ⬆
38
// [1] -> [2] -> [3] -> [4] -> [5]
39
- // ⬆
40
- // head
+ // ⬆
+ // head
41
42
43
+ // ⬇ ⬆
44
+ // [1] -> [2] -> [3] -> [4] <- [5]
45
46
47
head->next->next = head;
48
head->next = NULL;
49
return previous;
0 commit comments