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) 

Get hands-on with 1400+ tech skills courses.