forked from terrytong0876/LintCode-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
knowledgeHash.json
executable file
·331 lines (321 loc) · 8.38 KB
/
knowledgeHash.json
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
//https://github.com/awangdev/LintCode/blob/master/Java/
/*
//Format:
"name" : {
"nickname": "",
"property" : [
"x",
],
"problems" : [
"x",
]
}
*/
{
"int" : {
"nickname": "整数",
"property" : [
"Integer.parseInt(), INT_MAX, INT_MIN",
],
"problems" : [
"",
]
},
"String" : {
"nickname": "",
"property" : [
"toCharArry, charAt(), StringBuffer",
],
"problems" : [
"Multiply Strings",
]
},
"Recursive" : {
"nickname": "递归",
"property" : [
"找所有方案,搜索",
],
"problems" : [
"Generate Parentheses",
"Subsets",
"Permudation",
"NQueen"
]
},
"Iterative" : {
"nickname": "迭代",
"property" : [
"能递归,常常就能Iterative",
"Queue",
"Unique Permudation mark visited",
],
"problems" : [
"Subsets",
"Permudation",
]
},
"dp" : {
"nickname":"Dynamic Programming, DP, 动态规划",
"property" : [
"state,function,init,return",
],
"problems:" : [
"Backpack",
"BackPack II"
]
},
"union-find" : {
"nickname": "Disjoint Set, 并查集",
"property" : [],
"problems" : [
"Find the Weak Connected Component in the Directed Graph",
"Graph Valid Tree",
]
},
"Graph" : {
"nickname": "",
"property" : [
"x",
],
"problems" : [
"x",
]
},
"Binary tree" : {
"nickname": "二叉树",
"property" : [
"recursive, left, right",
"Binary Tree pre,in,post Traversal 都用到: DFS, Stack; divide && conquer(注意里面是return rst, 要懂得addAll); recursive with helper"
"Preorder Traversal: 1. Divide and conquer; 2. 1 stack: streo curr.val; push right, push left; 3. recursive with helper",
"Postorder Traversal: 1. Divide left&&right, conquer (add left, right, curr) 2. Two Stack(巧妙的s1,s2关系),最后output s2. 3. recursive with helper function",
"Inorder Traversal: 1. Divide and conquer; 2. 1 Stack: move all the way to left-down; add curr; move to right and push right; 3. Recursive with helper",
"Level Order Traversal: 1. Use queue, do bfs. 2. dfs: track with level number: each level add a new [] list in rst"
],
"problems" : [
"Binary Tree Paths",
"Binary Tree Preorder Traversal",
"Binary Tree Postorder Traversal",
"Binary Tree Inorder Traversal",
"Maximum Depth of Binary Tree",
"Convert Binary Search Tree to Doubly Linked List"
]
},
"Linked List" : {
"nickname": "",
"property" : [
"Singly linked list",
"slow/fast快慢指针"
],
"problems" : [
"Reverse LinkedList",
"Nth to last Node in List",
"Convert Sorted List to Binary Search Tree",
"Copy List with Random Pointer",
"Linked List Cycle"
]
},
"Binary Search" : {
"nickname": "",
"property" : [
"start + 1 < end",
"mid = start + (end - start)",
"不同的题目,match的condition可能会不太一样"
],
"problems" : [
"Search for a Range",
"Search Insert Position",
"Search in Rotated Sorted Array",
"Search a 2D Matrix",
"First Bad Version",
"Find Peak Element",
""
]
},
"Rotate" : {
"nickname": "翻转",
"property" : [
"中间截开一段,放在前面",
"常常需要分段翻转几回,做一个reverse function"
],
"problems" : [
"Reverse Words in a string",
"Rotated String",
"Recover Sorted Array"
]
},
"Trie" : {
"nickname": "Just a Tree",
"property" : [
"HashMap, store word, search word"
],
"problems" : [
"Implement Trie",
"Add and Search Word",
"Word Search II",
]
},
"Segment Tree" : {
"nickname": "线段树",
"property" : [
"Split by (start + end)/2. Make left,right child, then bind back to root",
"which of these intervals contain a given point",
"which of these points are in a given interval"
],
"problems" : [
"Segment Tree Query",
"Segment Tree Modify",
"Segment Tree Build",
"Interval Sum",
"Interval Minimum Number",
"Count of Smaller Number",
"Count of Smaller Number before itself",
]
},
"Expression Tree" : {
"nickname": "",
"property" : [
"Need to remember how to build the tree just like Max-tree using stack. 'while' add stack.pop() to node.left; if stack !empty, stack.peek().right = node; add node into stack",
],
"problems" : [
"Expression Evaludation",
]
},
"Toposort" : {
"nickname": "Topological Sort",
"property" : [
"NO CYCLE: Only possible if the graph has no directed cycle.",
"Must have a Sink vertex, the most outgoing vertex, where it all ends",
"via DFS (around 11:40 mins:): https://class.coursera.org/algo-003/lecture/52",
"Mark node visited, global current-label to mark the sequence from n to 1"
],
"problems" : [
"Course Schedule",
]
},
"Merge Sort" : {
"nickname": "",
"property" : [
"Find Middle (快慢pointer), merge(给元素按大小顺序排列,return list),recursively call sort() itself",
"Both average and worst case is nlogn",
"Merge sort is preffered on list: http://www.geeksforgeeks.org/why-quick-sort-preferred-for-arrays-and-merge-sort-for-linked-lists/",
"Merge sort array, it's slow than quick sort, due to O(N) space usage"
],
"problems" : [
"Sort List",
"Remove Duplicates from Uncorted List"
]
},
"Quick Sort" : {
"nickname": "快排, 排序界第一大算法",
"property" : [
"Average time nlogn, however worst case is n^2",
"Quick sort is preferred on arrays: http://www.geeksforgeeks.org/why-quick-sort-preferred-for-arrays-and-merge-sort-for-linked-lists/",
"Generally in-place sort array, without no extra space",
"Require random access to element, so it's not good for linked list, which could be worse O(n) time to access an element"
],
"problems" : [
"Partition Array",
]
},
"Insertion Sort" : {
"nickname": "",
"property" : [
"It's compared with Bubble sort, so I guess this is bad as well",
],
"problems" : [
"Insertion Sort List",
]
},
"Merge" : {
"nickname": "",
"property" : [
"",
],
"problems" : [
"Merge Sorted Array",
"Merge Sorted Array II",
"Merge k Sorted Arrays",
"Merge Intervals",
"Merge k sorted Lists",
"Merge Two Sorted Lists",
]
},
"Partition" : {
"nickname": "",
"property" : [
"如果是可以双向遍历,从两边开始遍历,找到满足条件可以swap的,swap",
"如果是list, 做个pre,post两个list, 把相应内容填充进去,然后把两个list链接起来不就好了"
],
"problems" : [
"Partition Array",
"Partition List",
"Partition Array by Odd and Even"
]
},
"Greedy Algorithm" : {
"nickname": "贪心",
"property" : [
"",
],
"problems" : [
"",
]
},
"Scan Line" : {
"nickname": "扫描线",
"property" : [
"把Interval分拆成Point{x,flag}.起点flag=1,终点flag=-1",
"用PriorityQueue可以sort这些点",
"维持一个count来判断同时又几个meeting在开,需要多少房间;一个人同时能参加所有meeting嘛,需要不重合",
"天上多少飞机同时在飞",
"根据count的情况merge interval, insert interval",
"在扫描时候,一定注意PriorityQueue里面在同一个point.x的很多点,可能同时发生,要全部处理完才能move on",
],
"problems" : [
"Meeting Rooms",
"Meeting Rooms II",
"Merge Intervals",
"Insert Interval",
"Planes in sky",
]
},
"Math" : {
"nickname": "数学",
"property" : [
"记得一些数学计算原理",
"Add 2 numbers: 用carrier = (sum / 10), rst = (sum % 10)",
"Binary: Integer part: bit = value %2; decimal part: bit = 1 if (num* 2 - 1) >= 0"
],
"problems" : [
"Add Two Numbers",
"Binary Representation"
]
},
"KMP" : {
"nickname": "String Seaching Algorithm",
"property" : [
"May or may not be testing this on strstr. Unlikely. https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm",
],
"problems" : [
"StrStr",
]
},
"System Design" : {
"nickname": "系统设计",
"property" : [
"读一些paper. 比如google的四篇文章",
"了解一些概念,去仔细理解一下: 什么CAP,SOA系统架构,Web常用的一些框架(什么NODE.JS等等),",
"对做网站等等的一些工具可以了解, 比如一个monitor系统: traffice, cpu, memory, harddrive, attack, serverice availability, 支付统计"
"dancres.github.io/Pages/ : 关于分布式系统",
"Google File System",
"Big Table",
"Map Reduce : 虽然Google已经不用了",
"Chubby",
"DynamoDB - Amazon: ",
"Akamai: * Global Distributed Content [CDN]"
],
"problems" : [
"",
]
}
}