Tree Height

Given the root of a binary tree, return its height.

Input Format

Integer n (number of nodes)
n space-separated integers in level-order (use -1 for null)

Output Format

Integer (height of the tree)

Sample Input

7
1 2 3 4 5 -1 -1

Sample Output

3

Try Your Code

← Back to Problems List