Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Height of a Binary Tree

XPChallenge Points: 10
levelLevel: Easy

Given the root of a binary tree, find the height of the tree.
The height is the number of nodes on the longest path from the root down to any leaf.

Example 1:

Input: root = [5,8,12,null,null,6,10]

Output: 3

Explanation:

The longest path is 5 → 12 → 10, so the height is 3.

Example 2:

Input: root = [4,null,7]

Output: 2

Explanation:

The longest path is 4 → 7, so the height is 2.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result