Summary for some exercise.
Some Functions
- list(map(str, list_)) $\Rightarrow$ convert each element in list_ to a str element
Exercise
Name |
Knowledge |
Copy List with Random Pointer |
LinkedList |
LRU Cache |
LinkedList, key_to_prev (list) |
2 Sum, 3 Sum |
HashSet |
Insert, Delete, GetRandom(1) |
HashSet |
Favorite Genres |
Construct a Dictionary |
Max Two Sum less than K |
Left, right pointers |
Most Common Word |
String process |
Serialize and Deserialize Binary Tree |
Tree Traverse |
Binary Tree Zigzag Level Order Traversal |
BFS Tree Traverse |
Binary Tree Maximum Path Sum |
Complex Recursion |
All Nodes Distance K in Binary Tree |
Complex Recursion |
Subtree of Another Tree |
Recursion |
Meeting Rooms II |
Heap |
Find Median from Data Stream |
Heap |
Flatten Nested List Iterator |
Iterator |
Sliding Window Maximum |
Sliding window, double-queue |
Partition Labels |
First Second Pointers |
Name |
Knowledge |
Search a 2D Matrix II |
Search |
Merge 2 Sorted Lists, Merge K Sorted Lists |
Recursion |
Compare Version Numbers |
Recursion |
Top K Frequent Words |
Sort |
Alien Dictionary |
Topological sort |
Course Schedule |
Topological sort |
Word Ladder |
BFS, Generate next myself |
Snakes and Ladders |
BFS |
The Maze II |
BFS, No closed list |
Number of Islands |
DFS, Graph traverse |
Word Search |
DFS, Backtracking |
Word Search II |
DFS, Trie tree, Generate next myself |
Critical Connections |
DFS, Tarjan |
Longest Palindromic Substring |
2-D DP |
Maximum Subarray |
1-D Contained DP |
Word Break |
1-D DP |
Trapping Rain Water |
Accumulated list |
460 TBD
More exercise
Name |
Knowledge |
Design Tic-Tac-Toe |
2d vector or int** |
Read N Characters Given read4 II - Call Multiple Times |
Create cache to hold extra char, and load from cache firstly next time |
Max Stack |
std::map (value to nodes), doubled linked list |
Maximum Frequency Stack |
unordered_map: frequency to stack of values, value to current frequency |
LRU Cache |
std::unordered_map (value to node), doubled linked list |
Design Hit Counter |
queue |
Valid Parenthesis String |
Analysis. Count left char and star char, or DFS |
Design Search Autocomplete System |
Trie Tree |
Peeking Iterator |
cache |
Basic Calculator III |
Infix expression, Stack, Queue, Deque |
Two Sum |
std::unordered_map, value to idx |
Rectangle Area |
use max to find bottom-left corner, use min to find top-right corner |
Rectangle Overlap |
save as above |
Max Points on a Line |
iterate to fit 2 points, store the line info |
Add Two Numbers |
traversal linked list |
Maximal Square |
2d DP. Edge length of maximum square which has the (i, j) to be bottom-right corner |
Excel Sheet Column Title |
minus 1 then %26 or /26 |
Unique Binary Search Trees |
1d DP. How many left and right node |
Island Perimeter |
DFS |
Car Pooling |
map |
Serialize and Deserialize N-ary Tree |
Pre-order DFS |
String Compression |
left right pointers |
Roman to Integer |
unordered_map: string to integer |
Remove Comments |
iteration on string, logics |
Smallest Rotation with Highest Score |
Analysis |
Work Break II |
DFS with memo |
Merge Intervals |
Sort |
Num of Squareful Arrays |
Permutations |
Maximum Size Subarray Sum Equals k |
accumulated array |
Binary Trees With Factors |
1-d DP |