Tree
Essential questions
- Binary Tree
- Maximum Depth of Binary Tree
- Invert/Flip Binary Tree
- Binary Search Tree
- Lowest Common Ancestor of a Binary Search Tree
Recommended practice questions
- Binary tree
- Same Tree
- Binary Tree Maximum Path Sum
- Binary Tree Level Order Traversal
- Lowest Common Ancestor of a Binary Tree
- Binary Tree Right Side View
- Subtree of Another Tree
- Construct Binary Tree from Preorder and Inorder Traversal
- Serialize and Deserialize Binary Tree
- Binary search tree
- Validate Binary Search Tree
- Kth Smallest Element in a BST
Graph
Essential questions
- Number of Islands (2)
- Flood Fill (2)
- 01 Matrix (2)
- Valid Sudoku
Recommended practice questions
- Breath-first search
- Rotting Oranges
- As Far From Land As Possible
- Network Delay Time
- Either search
- Clone Graph
- Pacific Altantic Water Flow
- Topological sorting
- Course Schedule
Heap
Techniques
Mention of k If you see a top or lowest k being mentioned in the question, it is usually a signal that a heap can be used to solve the problem, such as in Top K Frequent Elements.
If you require the top k elements use a Min Heap of size k. Iterate through each element, pushing it into the heap (for python heapq, invert the value before pushing to find the max). Whenever the heap size exceeds k, remove the minimum element, that will guarantee that you have the k largest elements.
Essential questions
- Merge K Sorted Lists
- K Closest Points to Origin
Recommended practice questions
- Top K Frequent Elements
- Find Median from Data Stream
Trie
Essential questions
- Implement Trie (Prefix Tree)
Recommended practice questions
- Add and Search Word
- Word Break
- Word Search II
Hash Table
Essential questions
- Two Sum (3)
- Ransom Note
Recommended practice questions
- Group Anagrams
- Insert Delete GetRandom O(1)
- First Missing Positive
- LRU Cache
- All O one Data Structure