← All problems

Maximum Depth of Binary Tree

Easy treesrecursionbfs LeetCode ↗
Find the maximum depth (longest root-to-leaf path) of a binary tree.

Hints (0/3 revealed)

Log in to reveal hints progressively.

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.