Data Structures19 sections · 729 units
Open in Course

Problem - Maximum Depth

Height of the tree

Given the root of a binary tree, return its maximum depth. Maximum depth is the number of nodes along the longest path from root to a leaf.

Example: A tree with root 3, left child 9, right child 20, and 20's children 15 and 7 has maximum depth 3. You're solving a foundational problem for recursive tree thinking.

The answer for a node depends on the answers for its children. Constraints: up to 10410^4 nodes, values from 100-100 to 100100.