Loading...
Loading...
Loading...
The height of a binary tree is the number of nodes on the longest path from the root down to a leaf. An empty tree has height 0. The tree may or may not be a binary search tree.
Example 1
Input
8 3 10 1 6 # 14 # # 4 7 13
Output
4
Example 2
Input
#
Output
0
Try the problem first. Open one hint at a time.
The height of a node is 1 plus the larger height of its two children.
A missing child has height 0.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor