Easy · Trees

Get height

Given the root of a binary tree, return its height: the number of nodes on the longest path from the root down to a leaf (0 for an empty tree).

Examples

Example 1

[3,9,20,·,·,15,7]

Output: height 3

Example 2

[1,2,3,4,·,·,·,8]

Output: height 4

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Trees problems