Given the root of a binary tree, return its maximum depth: the number of nodes along the longest path from the root down to the farthest leaf. This is the first problem to use the judge's typed TreeNode support: root is a real tree built from the JSON test fixture, not a flat array — your function must walk .left/.right pointers like a genuine LeetCode submission.
Input / output
root: TreeNode (JSON test fixture is a LeetCode-style level-order array using null for missing children, e.g. [3, 9, 20, null, null, 15, 7])int — the maximum depthExamples
root = [3, 9, 20, null, null, 15, 7] returns 3.root = [] returns 0 (an empty tree has depth 0).root = [1] returns 1.Constraints
0 <= number of nodes <= 10,000-100 <= node value <= 100Follow-up Can you solve it both recursively (depth-first) and iteratively with an explicit stack or a level-by-level breadth-first traversal, and explain when you'd prefer one over the other?