Course 8: Data Structure
- Linear data structure
- Queue: O(1) push, O(1) pop, O(1) top
- Stack: O(1) push, O(1) pop, O(1) top
- Hash: O(1) insert, O(1) delete, O(1) find;
- Open hash (array of linked list), closed hash (next array element, do not support delete);
- Rehash;
- HashTable vs. HashSet vs. HashMap
- Tree data structure
- Heap: O(logN) add, O(logN) remove, O(1) min/max
- Trie
Problems:
- Min-stack
- Implement a queue by two stacks O(1)
- Largest rectangle in histogram (very good analysis) (code 好的一点是在stack里事先加个-1,可以避开最左边的特殊情况)(pop时处理可以不用左右各走一遍)
- Max tree (same with largest rectangle): 找每个点的父亲,找左右两边第一个比它大的,两者相比小的那个是父亲
- LRU Cache (LFU Cache)
- Longest consecutive sequence
- Subarry sum
- Anagrams
- Find Median from data stream (heap)
- Word search II (trie)