Skip to content

Commit

Permalink
update 206 java, cheatsheet, progress
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Mar 8, 2024
1 parent 927e9f2 commit 3c3c29d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion data/progress.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
18 changes: 9 additions & 9 deletions data/to_review.txt
Original file line number Diff line number Diff line change
@@ -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)']
Expand All @@ -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)']
Expand All @@ -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']
Expand Down
24 changes: 14 additions & 10 deletions doc/cheatsheet/linked_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ class Solution(object):
// iteration
//---------------------------
// LC 206
// algorithm book (labu) p.297
// V0
public ListNode reverseList(ListNode head) {

if (head == null) {
Expand All @@ -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;
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3c3c29d

Please sign in to comment.