BO
BoscoSuen/leetcode
My leetcode 2020(Java & C++ & Go)
Topic with starred leetcode problems
Array
| Problem | Solution |
|---|---|
| 48. Rotate Image | Solution |
| 54. Spiral Matrix | 注意半边之后要重新判断 |
| 287. Find the Duplicate Number | Binary Search(C++) | Cycle Detection(Java) |
| 418. Sentence Screen Fitting | 建立退格的mapping |
Binary Search
Binary Search Tree(BST)
| Problem | Solution |
|---|---|
| 162. Find Peak Element | binary search找peak |
| 315. Count of Smaller Numbers After Self | Java Solution |
| 1008. Construct Binary Search Tree from Preorder Traversal | 递归O(n)解 |
Bit Manipulation
Dynamic Programming
Fenwick Tree / Binary Indexed Tree(BIT)
| Problem | Solution |
|---|---|
| 315. Count of Smaller Numbers After Self | C++ Solution |
Graph
Greedy
Iterator
| Problem | Solution |
|---|---|
| 341. Flatten Nested List Iterator | List Iterator |
Linked-List
| Problem | Solution |
|---|---|
| 148. Sort List | merge sort | space O(1) Solution |
Math
| Problem | Solution |
|---|---|
| 43. Multiply Strings | Solution |
| 50. Pow(x, n) | Solution |
| 837. New 21 Game | 算累加条件概率 |
Monotonic Queue
OOD
Random
| Problem | Solution |
|---|---|
| 528. Random Pick with Weight | Random + binarySeach |
| 384. Shuffle an Array | inside-out shuffle |
| 470. Implement Rand10() Using Rand7() | Solution |
Search
Segment Tree
| Problem | Solution |
|---|---|
| 307. Range Sum Query - Mutable | Segment Tree模版 |
Sliding Window
String
| Problem | Solution |
|---|---|
| 468.Validate IP Address | String split, NumberFormatException |
Quick Select(TopK)
| Problem | Solution |
|---|---|
| 215. Kth Largest Element in an Array | quick select |
| 973 K Closest Points to Origin | Quick Select |
| 347. Top K Frequent Elements | freq有上限, bucket sort |
Tree
| Problem | Solution |
|---|---|
| 199. Binary Tree Right Side View | preorder + level check |
| 662. Maximum Width of Binary Tree | Solution |
| 1110. Delete Nodes And Return Forest | Solution |
TreeMap(Ordered Map)
| Problem | Solution |
|---|---|
| 846. Hand of Straights | 注意follow up |