- LeetCode 103 – Binary Tree Zigzag Level Order Traversal
Level order with the direction alternating, and the answer people reach for first — reversing the queue — is the one that breaks. How you traverse and how you report are different things, and modifying the traversal to change the output is a category error.
- LeetCode 102 – Binary Tree Level Order Traversal
The problem that teaches BFS on trees, and everything depends on one line: capture the queue's size BEFORE draining the level. Looping on queue.size() re-evaluates a moving target and takes a meaningless slice. Also why deque beats a list in Python by a whole factor of n.
- LeetCode 101 – Symmetric Tree
Same Tree with two characters changed, and worth doing straight after it for exactly that reason. Symmetry is a property of a PAIR of nodes, so the recursion takes two arguments and crosses them. Plus the inorder-palindrome shortcut, and the tree that kills it.
- LeetCode 100 – Same Tree
The smallest possible tree recursion, and the template the harder tree problems are written against. Three base cases and one recursive step — and the ORDER of those base cases is the only thing that can go wrong, because each one protects the next from a null dereference.
- LeetCode 98 – Validate Binary Search Tree
The most famous wrong answer on the list: checking each node against its immediate children is not the BST property. A node's bounds come from every ancestor and narrow on the way down. Plus the Integer.MIN_VALUE sentinel trap, and the inorder alternative that generalises to Recover BST.