Challenge: Tree Depth

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


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.


A binary tree.


Display the depth of the tree.

Sample input

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