diff --git a/data/progress.txt b/data/progress.txt index 17e35128..cf075405 100644 --- a/data/progress.txt +++ b/data/progress.txt @@ -1,4 +1,4 @@ -20240308: 152,153(again),190,191,198,200 +20240308: 152,153(again),190,191,198,200,206(again) 20240307: 139(again),141,143(again) 20240306: 121,124(again),125,128,133(again) 20240305: 100,102,104,105(again) diff --git a/data/to_review.txt b/data/to_review.txt index f50b87e8..2ecbb95f 100644 --- a/data/to_review.txt +++ b/data/to_review.txt @@ -1,4 +1,4 @@ -2024-05-02 -> ['152,153(again),190,191,198,200'] +2024-05-02 -> ['152,153(again),190,191,198,200,206(again)'] 2024-05-01 -> ['139(again),141,143(again)'] 2024-04-30 -> ['121,124(again),125,128,133(again)'] 2024-04-29 -> ['100,102,104,105(again)'] @@ -7,7 +7,7 @@ 2024-04-24 -> ['39,48(again),49,53,54'] 2024-04-23 -> ['20,21,23,33(again)'] 2024-04-22 -> ['1,3,5,4,19'] -2024-04-11 -> ['152,153(again),190,191,198,200'] +2024-04-11 -> ['152,153(again),190,191,198,200,206(again)'] 2024-04-10 -> ['139(again),141,143(again)'] 2024-04-09 -> ['121,124(again),125,128,133(again)'] 2024-04-08 -> ['100,102,104,105(again)'] @@ -16,25 +16,25 @@ 2024-04-03 -> ['39,48(again),49,53,54'] 2024-04-02 -> ['20,21,23,33(again)'] 2024-04-01 -> ['1,3,5,4,19'] -2024-03-29 -> ['152,153(again),190,191,198,200'] +2024-03-29 -> ['152,153(again),190,191,198,200,206(again)'] 2024-03-28 -> ['139(again),141,143(again)'] 2024-03-27 -> ['121,124(again),125,128,133(again)'] 2024-03-26 -> ['100,102,104,105(again)'] 2024-03-25 -> ['73,76,79(again),91,25'] 2024-03-24 -> ['55(again),56,62,70'] -2024-03-21 -> ['152,153(again),190,191,198,200', '39,48(again),49,53,54'] +2024-03-21 -> ['152,153(again),190,191,198,200,206(again)', '39,48(again),49,53,54'] 2024-03-20 -> ['139(again),141,143(again)', '20,21,23,33(again)'] 2024-03-19 -> ['121,124(again),125,128,133(again)', '1,3,5,4,19'] 2024-03-18 -> ['100,102,104,105(again)'] 2024-03-17 -> ['73,76,79(again),91,25'] -2024-03-16 -> ['152,153(again),190,191,198,200', '55(again),56,62,70'] +2024-03-16 -> ['152,153(again),190,191,198,200,206(again)', '55(again),56,62,70'] 2024-03-15 -> ['139(again),141,143(again)'] 2024-03-14 -> ['121,124(again),125,128,133(again)'] -2024-03-13 -> ['152,153(again),190,191,198,200', '100,102,104,105(again)', '39,48(again),49,53,54'] +2024-03-13 -> ['152,153(again),190,191,198,200,206(again)', '100,102,104,105(again)', '39,48(again),49,53,54'] 2024-03-12 -> ['139(again),141,143(again)', '73,76,79(again),91,25', '20,21,23,33(again)'] -2024-03-11 -> ['152,153(again),190,191,198,200', '121,124(again),125,128,133(again)', '55(again),56,62,70', '1,3,5,4,19'] -2024-03-10 -> ['152,153(again),190,191,198,200', '139(again),141,143(again)', '100,102,104,105(again)'] -2024-03-09 -> ['152,153(again),190,191,198,200', '139(again),141,143(again)', '121,124(again),125,128,133(again)', '73,76,79(again),91,25'] +2024-03-11 -> ['152,153(again),190,191,198,200,206(again)', '121,124(again),125,128,133(again)', '55(again),56,62,70', '1,3,5,4,19'] +2024-03-10 -> ['152,153(again),190,191,198,200,206(again)', '139(again),141,143(again)', '100,102,104,105(again)'] +2024-03-09 -> ['152,153(again),190,191,198,200,206(again)', '139(again),141,143(again)', '121,124(again),125,128,133(again)', '73,76,79(again),91,25'] 2024-03-08 -> ['139(again),141,143(again)', '121,124(again),125,128,133(again)', '100,102,104,105(again)', '55(again),56,62,70', '39,48(again),49,53,54'] 2024-03-07 -> ['121,124(again),125,128,133(again)', '100,102,104,105(again)', '73,76,79(again),91,25', '20,21,23,33(again)'] 2024-03-06 -> ['100,102,104,105(again)', '73,76,79(again),91,25', '55(again),56,62,70', '1,3,5,4,19'] diff --git a/doc/cheatsheet/linked_list.md b/doc/cheatsheet/linked_list.md index 6b071077..3888162b 100644 --- a/doc/cheatsheet/linked_list.md +++ b/doc/cheatsheet/linked_list.md @@ -362,7 +362,7 @@ class Solution(object): // iteration //--------------------------- // LC 206 -// algorithm book (labu) p.297 +// V0 public ListNode reverseList(ListNode head) { if (head == null) { @@ -372,6 +372,17 @@ public ListNode reverseList(ListNode head) { ListNode _prev = null; while (head != null) { + /** + * NOTE !!!! + * + * 4 operations + * + * step 1) cache next + * step 2) point cur to prev + * step 3) move prev to cur + * step 4) move cur to next + * + */ ListNode _next = head.next; head.next = _prev; _prev = head; @@ -394,15 +405,8 @@ public ListNode reverseList(ListNode head) { // algorithm book (labu) p.290 // IDEA : Recursive // https://leetcode.com/problems/reverse-linked-list/editorial/ -public ListNode reverseList_3(ListNode head) { - if (head == null || head.next == null) { - return head; - } - ListNode p = reverseList_3(head.next); - head.next.next = head; - head.next = null; - return p; -} +// https://github.com/yennanliu/CS_basics/blob/master/leetcode_java/src/main/java/LeetCodeJava/LinkedList/ReverseLinkedList.java +// same as above ``` #### 1-1-5) Reverse *nodes in [a,b]* linked list (iteration) diff --git a/leetcode_java/src/main/java/LeetCodeJava/LinkedList/ReverseLinkedList.java b/leetcode_java/src/main/java/LeetCodeJava/LinkedList/ReverseLinkedList.java index 7abd80fd..3921eaba 100644 --- a/leetcode_java/src/main/java/LeetCodeJava/LinkedList/ReverseLinkedList.java +++ b/leetcode_java/src/main/java/LeetCodeJava/LinkedList/ReverseLinkedList.java @@ -18,6 +18,17 @@ public ListNode reverseList(ListNode head) { ListNode _prev = null; while (head != null) { + /** + * NOTE !!!! + * + * 4 operations + * + * step 1) cache next + * step 2) point cur to prev + * step 3) move prev to cur + * step 4) move cur to next + * + */ ListNode _next = head.next; head.next = _prev; _prev = head;