Challenge: Tree Depth

Let’s find the depth of a binary tree using recursion.

Problem

Given a binary tree, find its depth. The depth of the root is 0. The depth of the tree is the number of edges in the longest branch from the root to the leaf.

Input

A binary tree.

Output

Display the depth of the tree.

Sample input

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.