Pattern Recognition Drill
Easy Trees
The Problem
Find the height of a binary tree.
What approach would you use?
Think about it before scrolling down.
Recurse on both children, return 1 + max(left, right). O(n) visiting all nodes.
Level-order traversal, count levels. Same O(n) but more complex code.
Common Trap
Clarify the height convention with the interviewer: edge-count vs node-count (off by one).