← All problems
Maximum Depth of Binary Tree
Find the maximum depth (longest root-to-leaf path) of a binary tree.
Complexity
Time O(n), Space O(h) recursion
Common pitfalls
- Counting nodes vs edges inconsistently
- Forgetting the null base case
Your solution
Log in to save your code and track progress.