The recursive insight: the depth of a tree equals 1 plus the maximum depth of its subtrees.
function maxDepth(root):
if root == null:
return 0
leftDepth = maxDepth(root.left)
rightDepth = maxDepth(root.right)
return 1 + max(leftDepth, rightDepth)
Base case: null node has depth 0.
Recursive case: depth is 1 (for current node) plus the deeper subtree.
Time: . Visit each node once.
Space: . Recursion depth equals tree height.
This three-line solution captures the essence of recursive tree thinking. Many harder problems are variations of this pattern.