Small balanced tree
Input
compute_height(TreeNode(1, TreeNode(2), TreeNode(3)))
Output
2
Root plus one level of children -> height is 2.
Full lesson preview
Find the height of a binary tree (empty tree height = 0).
Problem statement
Task
Examples
Input
compute_height(TreeNode(1, TreeNode(2), TreeNode(3)))
Output
2
Root plus one level of children -> height is 2.
Input format
Output format
Constraints
Samples
Input
compute_height(None)
Output
0
Empty tree has height 0.