Skip to content

Commit

Permalink
update 104 java, progress
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Mar 5, 2024
1 parent d8c464a commit bf45a6f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 41 deletions.
2 changes: 1 addition & 1 deletion data/progress.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
20240305: 100
20240305: 100,102,104
20240304: 73,76,79(again),91,25
20240303: 55(again),56,62,70
20240229: 39,48(again),49,53,54
Expand Down
18 changes: 9 additions & 9 deletions data/to_review.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
2024-04-29 -> ['100']
2024-04-29 -> ['100,102,104']
2024-04-28 -> ['73,76,79(again),91,25']
2024-04-27 -> ['55(again),56,62,70']
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-08 -> ['100']
2024-04-08 -> ['100,102,104']
2024-04-07 -> ['73,76,79(again),91,25']
2024-04-06 -> ['55(again),56,62,70']
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-26 -> ['100']
2024-03-26 -> ['100,102,104']
2024-03-25 -> ['73,76,79(again),91,25']
2024-03-24 -> ['55(again),56,62,70']
2024-03-21 -> ['39,48(again),49,53,54']
2024-03-20 -> ['20,21,23,33(again)']
2024-03-19 -> ['1,3,5,4,19']
2024-03-18 -> ['100']
2024-03-18 -> ['100,102,104']
2024-03-17 -> ['73,76,79(again),91,25']
2024-03-16 -> ['55(again),56,62,70']
2024-03-13 -> ['100', '39,48(again),49,53,54']
2024-03-13 -> ['100,102,104', '39,48(again),49,53,54']
2024-03-12 -> ['73,76,79(again),91,25', '20,21,23,33(again)']
2024-03-11 -> ['55(again),56,62,70', '1,3,5,4,19']
2024-03-10 -> ['100']
2024-03-10 -> ['100,102,104']
2024-03-09 -> ['73,76,79(again),91,25']
2024-03-08 -> ['100', '55(again),56,62,70', '39,48(again),49,53,54']
2024-03-07 -> ['100', '73,76,79(again),91,25', '20,21,23,33(again)']
2024-03-06 -> ['100', '73,76,79(again),91,25', '55(again),56,62,70', '1,3,5,4,19']
2024-03-08 -> ['100,102,104', '55(again),56,62,70', '39,48(again),49,53,54']
2024-03-07 -> ['100,102,104', '73,76,79(again),91,25', '20,21,23,33(again)']
2024-03-06 -> ['100,102,104', '73,76,79(again),91,25', '55(again),56,62,70', '1,3,5,4,19']
2024-03-05 -> ['73,76,79(again),91,25', '55(again),56,62,70', '39,48(again),49,53,54']
2024-03-04 -> ['55(again),56,62,70', '20,21,23,33(again)']
2024-03-03 -> ['39,48(again),49,53,54', '1,3,5,4,19']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,25 @@ public int maxDepth_1(TreeNode root) {
}


// V0
// public int maxDepth(TreeNode root) {
//
// if (root == null){
// return 0;
// }
//
// int resultL = findDepth(root.left, 0);
// int resultR = findDepth(root.right, 0);
//
// return Math.max(resultL, resultR);
// }
//
// private int findDepth(TreeNode root, int layer) {
//
// if (root == null){
// return layer;
// }
//
// if (root.left != null){
// layer += 1;
// findDepth(root.left, layer);
// }
//
// if (root.right != null){
// layer += 1;
// findDepth(root.right, layer);
// }
//
// return layer;
// }
// V0''
// IDEA : DFS (RECURSION)
public int maxDepth__(TreeNode root) {

if (root == null){
return 0;
}
int cur = 0;
int depth = 0;
return dfs(root, cur, depth);
}
private int dfs(TreeNode root, int cur, int depth){
if (root == null){
depth = Math.max(cur, depth);
return depth;
}
return Math.max(dfs(root.left, cur+1, depth), dfs(root.right, cur+1, depth));
}


// V1
// IDEA : RECURSION
Expand Down

0 comments on commit bf45a6f

Please sign in to comment.