-
Notifications
You must be signed in to change notification settings - Fork 4
/
00_Summary
42 lines (28 loc) · 1.06 KB
/
00_Summary
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Summary
Stack: pop, push, peek
HashMap: get, put, containsKey, remove
HashSet: add
LinkedList: peek, add, remove(poll)
String --> substring(beginIndes, endIndex)
beginIndex -- the begin index, inclusive.
endIndex -- the end index, exclusive.
in DFS function, do not use index++, use index+1, should be very careful on this!!! index++ is running then add. if really want to use this, use prefix ++, ++index;
PQ+Comparator:
PriorityQueue<String> pq = new PriorityQueue<String>(new Comparator<String>{
public int compare(String s, String t){
return s.compareTo(t);
}
});
Comparator:
Regular:
Comparator<Developer> byName = new Comparator<Developer>() {
@Override
public int compare(Developer o1, Developer o2) {
return o1.getName().compareTo(o2.getName());
}
};
Lamda:
Comparator<Developer> byName =
(Developer o1, Developer o2)->o1.getName().compareTo(o2.getName());
Union Find介绍:
https://github.com/labuladong/fucking-algorithm/blob/master/%E7%AE%97%E6%B3%95%E6%80%9D%E7%BB%B4%E7%B3%BB%E5%88%97/UnionFind%E7%AE%97%E6%B3%95%E8%AF%A6%E8%A7%A3.md