Skip to content

Commit

Permalink
update progress
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Jun 7, 2024
1 parent 2b8863e commit a9a4c69
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 26 deletions.
2 changes: 1 addition & 1 deletion data/progress.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
20240607: 235,236,496,503
20240607: 235(ok),236,496,503,110(ok)
20240606: 206,143,138(again),141,needcode_tree,226,104,110(again!!!)
20240605: 150,22(again),739(again!!!),needcode_linkedlist
20240604: 567(todo),needcode_array_hash,needcode_sliding_window,567(again),needcode_stack,155(again)
Expand Down
17 changes: 9 additions & 8 deletions data/to_review.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
2024-08-01 -> ['235(ok),236,496,503,110(ok)']
2024-07-31 -> ['206,143,138(again),141,needcode_tree,226,104,110(again!!!)']
2024-07-30 -> ['150,22(again),739(again!!!),needcode_linkedlist']
2024-07-29 -> ['567(todo),needcode_array_hash,needcode_sliding_window,567(again),needcode_stack,155(again)']
Expand All @@ -17,7 +18,7 @@
2024-07-14 -> ['73,200,70,323(again)']
2024-07-13 -> ['207,79,206,213,198']
2024-07-12 -> ['212(todo),211,338,208(again)']
2024-07-11 -> ['347,253(todo),91(todo),217']
2024-07-11 -> ['235(ok),236,496,503,110(ok)', '347,253(todo),91(todo),217']
2024-07-10 -> ['206,143,138(again),141,needcode_tree,226,104,110(again!!!)', '226,98,253(todo)']
2024-07-09 -> ['150,22(again),739(again!!!),needcode_linkedlist', '104,230,102,100']
2024-07-08 -> ['567(todo),needcode_array_hash,needcode_sliding_window,567(again),needcode_stack,155(again)', '105,106']
Expand All @@ -29,27 +30,27 @@
2024-07-01 -> ['143,15,268,141,139']
2024-06-30 -> ['21,20,19,271,269']
2024-06-29 -> ['417(again),33,153,152']
2024-06-28 -> ['424,297(todo),295(todo),39']
2024-06-28 -> ['235(ok),236,496,503,110(ok)', '424,297(todo),295(todo),39']
2024-06-27 -> ['206,143,138(again),141,needcode_tree,226,104,110(again!!!)', '55,54(todo),53(again),435(again),49,48(todo),300(again)']
2024-06-26 -> ['150,22(again),739(again!!!),needcode_linkedlist', '56']
2024-06-25 -> ['567(todo),needcode_array_hash,needcode_sliding_window,567(again),needcode_stack,155(again)', '62,572,57']
2024-06-24 -> ['146,460,582(ok*),139(ok),322(todo)', '322,191,190']
2024-06-23 -> ['127,742(again),133(again),207(ok*),261(ok)', '73,200,70,323(again)']
2024-06-22 -> ['128,261', '207,79,206,213,198']
2024-06-21 -> ['005,003(again)', '212(todo),211,338,208(again)']
2024-06-20 -> ['347,253(todo),91(todo),217']
2024-06-20 -> ['235(ok),236,496,503,110(ok)', '347,253(todo),91(todo),217']
2024-06-19 -> ['206,143,138(again),141,needcode_tree,226,104,110(again!!!)', '11,647,261(again),133(again)', '226,98,253(todo)']
2024-06-18 -> ['150,22(again),739(again!!!),needcode_linkedlist', '143,15,268,141,139', '104,230,102,100']
2024-06-17 -> ['567(todo),needcode_array_hash,needcode_sliding_window,567(again),needcode_stack,155(again)', '21,20,19,271,269', '105,106']
2024-06-16 -> ['146,460,582(ok*),139(ok),322(todo)', '417(again),33,153,152', '242,235']
2024-06-15 -> ['127,742(again),133(again),207(ok*),261(ok)', '424,297(todo),295(todo),39', '371']
2024-06-15 -> ['235(ok),236,496,503,110(ok)', '127,742(again),133(again),207(ok*),261(ok)', '424,297(todo),295(todo),39', '371']
2024-06-14 -> ['206,143,138(again),141,needcode_tree,226,104,110(again!!!)', '128,261', '55,54(todo),53(again),435(again),49,48(todo),300(again)', '121,252']
2024-06-13 -> ['150,22(again),739(again!!!),needcode_linkedlist', '005,003(again)', '56', '125']
2024-06-12 -> ['567(todo),needcode_array_hash,needcode_sliding_window,567(again),needcode_stack,155(again)', '62,572,57']
2024-06-12 -> ['235(ok),236,496,503,110(ok)', '567(todo),needcode_array_hash,needcode_sliding_window,567(again),needcode_stack,155(again)', '62,572,57']
2024-06-11 -> ['206,143,138(again),141,needcode_tree,226,104,110(again!!!)', '146,460,582(ok*),139(ok),322(todo)', '11,647,261(again),133(again)', '322,191,190']
2024-06-10 -> ['150,22(again),739(again!!!),needcode_linkedlist', '127,742(again),133(again),207(ok*),261(ok)', '143,15,268,141,139', '73,200,70,323(again)']
2024-06-09 -> ['206,143,138(again),141,needcode_tree,226,104,110(again!!!)', '567(todo),needcode_array_hash,needcode_sliding_window,567(again),needcode_stack,155(again)', '128,261', '21,20,19,271,269', '207,79,206,213,198']
2024-06-08 -> ['206,143,138(again),141,needcode_tree,226,104,110(again!!!)', '150,22(again),739(again!!!),needcode_linkedlist', '146,460,582(ok*),139(ok),322(todo)', '005,003(again)', '417(again),33,153,152', '212(todo),211,338,208(again)']
2024-06-10 -> ['235(ok),236,496,503,110(ok)', '150,22(again),739(again!!!),needcode_linkedlist', '127,742(again),133(again),207(ok*),261(ok)', '143,15,268,141,139', '73,200,70,323(again)']
2024-06-09 -> ['235(ok),236,496,503,110(ok)', '206,143,138(again),141,needcode_tree,226,104,110(again!!!)', '567(todo),needcode_array_hash,needcode_sliding_window,567(again),needcode_stack,155(again)', '128,261', '21,20,19,271,269', '207,79,206,213,198']
2024-06-08 -> ['235(ok),236,496,503,110(ok)', '206,143,138(again),141,needcode_tree,226,104,110(again!!!)', '150,22(again),739(again!!!),needcode_linkedlist', '146,460,582(ok*),139(ok),322(todo)', '005,003(again)', '417(again),33,153,152', '212(todo),211,338,208(again)']
2024-06-07 -> ['206,143,138(again),141,needcode_tree,226,104,110(again!!!)', '150,22(again),739(again!!!),needcode_linkedlist', '567(todo),needcode_array_hash,needcode_sliding_window,567(again),needcode_stack,155(again)', '127,742(again),133(again),207(ok*),261(ok)', '424,297(todo),295(todo),39', '347,253(todo),91(todo),217']
2024-06-06 -> ['150,22(again),739(again!!!),needcode_linkedlist', '567(todo),needcode_array_hash,needcode_sliding_window,567(again),needcode_stack,155(again)', '146,460,582(ok*),139(ok),322(todo)', '128,261', '11,647,261(again),133(again)', '55,54(todo),53(again),435(again),49,48(todo),300(again)', '226,98,253(todo)']
2024-06-05 -> ['567(todo),needcode_array_hash,needcode_sliding_window,567(again),needcode_stack,155(again)', '146,460,582(ok*),139(ok),322(todo)', '127,742(again),133(again),207(ok*),261(ok)', '005,003(again)', '143,15,268,141,139', '56', '104,230,102,100']
Expand Down
93 changes: 76 additions & 17 deletions leetcode_java/src/main/java/dev/workspace3.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,23 +276,23 @@ public boolean isAnagram(String s, String t) {

// LC 235
// DFS
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {

if (root.equals(p) || root.equals(q)) {
return root;
}

// BST property : right > root > left
if (p.val > root.val && q.val > root.val){
return this.lowestCommonAncestor(root.right, p, q);
}
if (p.val < root.val && q.val < root.val){
return this.lowestCommonAncestor(root.left, p, q);
}

// p, q are in different side (sub tree)
return root;
}
// public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
//
// if (root.equals(p) || root.equals(q)) {
// return root;
// }
//
// // BST property : right > root > left
// if (p.val > root.val && q.val > root.val){
// return this.lowestCommonAncestor(root.right, p, q);
// }
// if (p.val < root.val && q.val < root.val){
// return this.lowestCommonAncestor(root.left, p, q);
// }
//
// // p, q are in different side (sub tree)
// return root;
// }

// LC 105
// DFS
Expand Down Expand Up @@ -4017,5 +4017,64 @@ private int height(TreeNode root) {
// return false;
// }

// LC 110
public boolean isBalanced_2(TreeNode root) {

if (root == null){
return true;
}

return this.isBalanced_2(root.left) &&
this.isBalanced_2(root.right) &&
Math.abs(this.getMaxDepth(root.left) - this.getMaxDepth(root.right)) < 2;
}

public int getMaxDepth(TreeNode root){
if (root == null){
return 0;
}
return Math.max(
this.getMaxDepth(root.left)+1,
this.getMaxDepth(root.right)+1
);
}

// LC 235
// dfs
// 4.10
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {

// if (root == null){
// return root; // ?
// }

// NOTE !!! equals
if (root.equals(p) || root.equals(q)){
return root;
}

// case 1) root > p, q
if (root.val > p.val && root.val > q.val){
return this.lowestCommonAncestor(root.left, p, q);
}

// case 1') root < p, q
if (root.val < p.val && root.val < q.val){
return this.lowestCommonAncestor(root.right, p, q);
}

// case 2) root is between p, q
// -> // return root directly, since p, q MUST in different sides
// if ((root.val < p.val && root.val > q.val) || (root.val > p.val && root.val < q.val)){
// return root;
// }
return root;

// case 2) found p, q in different side
// case 3) root == p or root == q

//return null;
}


}

0 comments on commit a9a4c69

Please sign in to comment.