Skip to content

Commit e64f056

Browse files
authored
Update 49 2022 0920 CTCI 2nd.md
1 parent db244a3 commit e64f056

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

紀錄/49 2022 0920 CTCI 2nd.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,70 @@ This section covers how to prepare for technical questions (without wasting your
2828
* What Good Coding Looks Like
2929
* Don’t Give Up!**
3030

31+
---
32+
33+
1. Listen
34+
2. Example
35+
3. Brute Force
36+
4. Optimize (BUD)
37+
5. Walk Through
38+
6. Implement
39+
7. Tests
40+
41+
---
42+
43+
2 sums
44+
In a array return the indexes, which sum is T
45+
Z, not sorted, no duplicate, only 1, if no then empty/null
46+
47+
---
48+
49+
Yu
50+
51+
1. Listen
52+
1. N or Z, Sorted or not, duplicate, only 1 answer
53+
54+
2. [n,n,n,], 0
55+
3. 兩兩排列組合,交換率減少重複
56+
4. 當前的數必定有一對應差值,我們將其記憶下來,一旦出現對應差值時則必有解,唯獨解不是差值而是相對應的 index,所以必須要有 mapping 的表
57+
58+
59+
5. walk through
60+
```
61+
when visit a index
62+
if I know the element of index is a some diff number
63+
then the result is the mapping index and current index
64+
else I memerize the diff n and mapping its index.
65+
```
66+
67+
map d
68+
69+
7.
70+
71+
---
72+
73+
Louis
74+
75+
1. If no sum is T, then?
76+
2. Example
77+
[1,2,3], 4 -> [0,2]
78+
[...,-1, 2, 5, 6...], 4 -> [0,2]
79+
[1...9999], 4
80+
[1,2,9999], 4
81+
[1,1,2,2], 4
82+
[], 0
83+
[1,3,2,2], 4
84+
85+
3. Brute
86+
- 每個東西兩兩相加,如果是 target 就得到答案。
87+
88+
---
89+
90+
Allen
91+
92+
3. Complexity
93+
Time: O(n^2)
94+
Space: O(1)
95+
96+
5. Walk Through
97+

0 commit comments

Comments
 (0)