Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Mar 15, 2024
1 parent e52838b commit a70eaf2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
13 changes: 13 additions & 0 deletions doc/cheatsheet/bfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,19 @@ class Solution(object):
node = root
stack = []
while stack or node is not None:
"""
NOTE !!!
since BST has property:
left sub tree < root < right sub tree
-> so in order to get "sum over bigger tree"
-> we first visit all right sub tree
-> get cumsum
-> then to left
-> visit ordering : right sub tree -> left sub tree
"""
while node is not None:
stack.append(node)
node = node.right
Expand Down
2 changes: 1 addition & 1 deletion doc/cheatsheet/java_trick.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ List<String> _list = new ArrayList<>(); // this is List (with "List" keyword)
int[] _array = {0,1,2,3}; // this is Array (without "List" keyword)
```

### 1-0-1) Init an List
### 1-0-1) Init a List
```java
// java

Expand Down
36 changes: 25 additions & 11 deletions leetcode_java/src/main/java/dev/Test2.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package dev;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Test2 {
public static void main(String[] args) {

Expand All @@ -8,18 +12,28 @@ public static void main(String[] args) {
// System.out.println(x);
// }

int r = 3;
System.out.println("start");
while (r >= 0){
r -= 1;
System.out.println(r);
if (r == 2){
break;
//continue;
}
}
System.out.println("end");
// int r = 3;
// System.out.println("start");
// while (r >= 0){
// r -= 1;
// System.out.println(r);
// if (r == 2){
// break;
// //continue;
// }
// }
// System.out.println("end");


System.out.println(Arrays.asList(1,2,3));

System.out.println(Arrays.asList(1,2));

List<Integer> x = Arrays.asList(1, 2);

System.out.println(new int[]{1,2,3});

List<Integer> x2 = new ArrayList<>(Arrays.asList(1, 2, 3));
}

}
2 changes: 1 addition & 1 deletion leetcode_python/Depth-First-Search/kill-process.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def killProcess(self, pid, ppid, kill):
res = []
while q:
for i in range(len(q)):
tmp = q.pop(-1)
tmp = q.pop(-1) # TODO check : should be pop(0) ???
res.append(tmp)
for _ in d[tmp]:
q.append(_)
Expand Down

0 comments on commit a70eaf2

Please sign in to comment.