Algorithms Playbook
← All problems
EasyTraversals →Similar to: Maximum Depth of Binary Tree

How tall is the tree?

Problem

Given the root of a binary tree, return its maximum depth: the number of nodes along the longest path from the root down to a leaf. An empty tree has depth 0.

Examples

Input: [3, 9, 20, null, null, 15, 7]

Output: 3

Input: []

Output: 0

Hints

    Try it first. Every hint reveals a bit more.

    Solution