Solution Review: Find Number of Leaf Nodes

Let’s take a detailed look at the previous challenge’s solution.

Solution

We’ll calculate the total number of leaf nodes in the tree by adding the number of leaf nodes in the right subtree with the number of leaf nodes in the left subtree.

Total leaf nodes = (number of leaf nodes in the right subtree) + (number of leaf nodes in the left subtree) 

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