Skip to content

Commit 4126a55

Browse files
committed
update doc/cheatsheet format
1 parent 1d1d28b commit 4126a55

File tree

9 files changed

+89
-31
lines changed

9 files changed

+89
-31
lines changed

doc/cheatsheet/Collection.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Collection cheatsheet
22

3-
### 1) collection.Counter
3+
## 0) Concept
4+
5+
### 0-1) Framework
6+
7+
### 0-2) Pattern
8+
9+
## 1) General form
10+
11+
### 1-1) collection.Counter
412
```python
513
import collections
614
s = ['a','b','c','c']
@@ -10,7 +18,7 @@ print (c.keys())
1018
print (c.values())
1119
```
1220

13-
### 1-1) Important method - most_common()
21+
### 1-2) Important method - most_common()
1422
```python
1523
# 451 Sort Characters By Frequency
1624
import collections
@@ -23,7 +31,7 @@ for item, freq in count:
2331
#b 1
2432
```
2533

26-
### 2) collection.defaultdict (int, list...)
34+
### 1-3) collection.defaultdict (int, list...)
2735
```python
2836
import collections
2937
s = ['a','b','c','c']

doc/cheatsheet/bfs.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# BFS cheatsheet
22

3-
### 1) General form
3+
## 0) Concept
4+
5+
### 0-1) Framework
6+
7+
### 0-2) Pattern
8+
9+
## 1) General form
410
```python
511
# V1 : via collections.deque
612
import collections
@@ -34,6 +40,10 @@ def bfs(root):
3440

3541
```
3642

43+
### 1-1) Basic OP
44+
45+
## 2) LC Example
46+
3747
### 2-1) Word Ladder
3848
```python
3949
# 127 Word Ladder
@@ -55,4 +65,4 @@ class Solution(object):
5565
bfs.append((newWord, length + 1))
5666
return 0
5767

58-
```
68+
```

doc/cheatsheet/binary_search.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Binary Search Cheatsheet
22

3-
### 1) General form
3+
## 0) Concept
4+
5+
### 0-1) Framework
6+
7+
### 0-2) Pattern
8+
9+
## 1) General form
410
```python
511
def binary_search(nums, target):
612
l, r = 0, len(nums)-1
@@ -15,6 +21,8 @@ def binary_search(nums, target):
1521
return -1
1622

1723
```
24+
## 2) LC Example
25+
1826

1927
### 2-1) For loop + binary search
2028
```python

doc/cheatsheet/hash_map.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# Hash Map Cheatsheet
22

3-
### 1) General form
3+
## 0) Concept
44

5+
### 0-1) Framework
6+
7+
### 0-2) Pattern
8+
9+
## 1) General form
510
<p align="center"><img src ="https://github.com/yennanliu/CS_basics/blob/master/doc/pic/hash_table_2.png" ></p>
611

712
- Definition
@@ -20,4 +25,6 @@
2025

2126
- Ref
2227
- https://blog.techbridge.cc/2017/01/21/simple-hash-table-intro/
23-
- https://www.freecodecamp.org/news/hash-tables/
28+
- https://www.freecodecamp.org/news/hash-tables/
29+
30+
## 2) LC Example

doc/cheatsheet/heap.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# Heap cheatsheet
22

3-
### 1) General form
4-
- dev
3+
## 0) Concept
54

6-
### 2) Heap VS Stack VS Queue
7-
- dev
5+
### 0-1) Framework
86

9-
### 3) Basic OP
10-
- dev
7+
### 0-2) Pattern
118

12-
### 4-1) Heap sort
9+
## 1) General form
10+
11+
### 1-1) Basic OP
12+
13+
### 1-2) Heap VS Stack VS Queue
14+
15+
### 1-3) Heap sort
1316
```python
1417
# https://docs.python.org/zh-tw/3/library/heapq.html
1518
def heapsort(iterable):
@@ -24,10 +27,11 @@ def heapsort(iterable):
2427

2528
```
2629

27-
### 4-2) Priority Queue
28-
- dev
30+
### 1-4) Priority Queue
31+
32+
## 2) LC Example
2933

30-
### 4-3) Kth Largest Element in a Stream
34+
### 2-1) Kth Largest Element in a Stream
3135
```python
3236
# 703 Kth Largest Element in a Stream
3337
class KthLargest(object):

doc/cheatsheet/palindrome.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
# Palindrome cheatsheet
22

3-
### 1) General form
3+
## 0) Concept
4+
5+
### 0-1) Framework
6+
7+
### 0-2) Pattern
8+
9+
## 1) General form
410
```python
511
def check_palindrome(x):
612
return x == x[::-1]
713
```
814

9-
### 2) Example
15+
### 1-1) Basic OP
16+
17+
## 2) LC Example
1018

11-
#### 2-1)
19+
#### 2-1) Palindrome Partitioning
1220
```python
1321
# 131 Palindrome Partitioning
1422
class Solution(object):

doc/cheatsheet/queue.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
# Queue cheatsheet
22

3-
### 1) General form
3+
## 0) Concept
44

5-
### 2-1) Queue
5+
### 0-1) Framework
66

7-
### 2-2) Double-ended Queue
7+
### 0-2) Pattern
8+
9+
## 1) General form
10+
11+
### 1-1) Basic OP
12+
13+
### 1-2) Queue
14+
15+
### 1-3) Double-ended Queue
816
```python
917
# https://pymotw.com/2/collections/deque.html
1018
import collections
@@ -19,5 +27,4 @@ print ('pop_left:' , d.popleft())
1927
print (d)
2028

2129
```
22-
23-
### 2-3) Stack simulate Queue
30+
### 1-4) Stack simulate Queue

doc/cheatsheet/string.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# String cheatsheet
22

3-
### 1) General form
4-
- dev
3+
## 0) Concept
54

6-
### 2) Example
5+
### 0-1) Framework
76

8-
#### 2-1) go through 2 string, keep comparing digits in eash string
7+
### 0-2) Pattern
8+
9+
## 1) General form
10+
11+
## 2) LC Example
12+
13+
### 2-1) go through 2 string, keep comparing digits in eash string
914
```python
1015
# 165 Compare Version Number
1116
class Solution(object):
@@ -27,7 +32,7 @@ class Solution(object):
2732
return 0
2833
```
2934

30-
#### 2-2) String -> Int
35+
### 2-2) String -> Int
3136
```python
3237
# 445 Add Two Numbers II
3338
# 394 Decode String

doc/progress.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
- 606 Construct String from Binary Tree
3939
- 459 Repeated Substring Pattern
4040
- Review:
41+
- `cheatsheet/dfs.md`
4142
- 098 Validate Binary Search Tree
4243
- [AMZ V1](https://github.com/yennanliu/CS_basics/blob/master/doc/leetcode_company_V1/Amazon%20-%20LeetCode.pdf) - 12/13
4344
- Review `data/to_review.txt`

0 commit comments

Comments
 (0)