Tree problems cheat sheet - patterns I've compiled
Trees are my favorite topic and I've compiled patterns that cover 90% of tree interview questions:
1. DFS traversals (inorder, preorder, postorder - iterative + recursive)
2. Level order traversal (BFS + variations like zigzag)
3. Path problems (root to leaf sum, max path sum)
4. Construction (from inorder+preorder, from array)
5. BST specific (validate BST, kth smallest, LCA in BST)
6. Structural (symmetric tree, same tree, subtree check)
7. Modification (invert tree, flatten to linked list, serialize/deserialize)
Most tree problems reduce to one of these 7 patterns. Master them and you'll be confident in interviews.