Trees
A deep dive into recursion; the gateway to heap and graph.
Lessons
- ✓01
Recognizing tree problems
The TreeNode node, recursion as the natural tool, traversals, and the O(n)/O(h) complexity.
- ✓02
Pattern 1: Recursive DFS
The recursive template that solves most trees: solve the children, then combine.
- ✓03
Pattern 2: Level-order BFS
When the question is per level, breadth-first search with a queue processes layer by layer.
- ✓04
Pattern 3: Binary search tree (BST)
The left < node < right property, which gives O(h) search and sorted order via the in-order traversal.
- ✓05
Pattern 4: Construction and serialization
Rebuilding a tree from traversals and serializing it without ambiguity.
- ✓06
Pattern 5: Trie (prefix tree)
The character tree that makes prefix and word search highly efficient.
- ✓07
Synthesis: which pattern to use?
The Trees section's decision tree and the general quiz before the final exam.
1 easy + 1 medium + 1 hard — unseen problems
With hidden test cases, just like the real LeetCode. This is where you confirm you can leave the section solving any problem of the topic.