Maximum Depth of a Binary Tree

Easy · Trees · about 10 minutes

Asked at Amazon, LinkedIn, Microsoft, Apple.

Count the nodes along the deepest downward path of a binary tree, from the root to the farthest leaf, and return that count. A tree with no nodes has depth 0.

Related guides