Challenge: Find Number of Leaf Nodes

Let’s find the number of leaf nodes present in a binary tree using recursion.

Problem

Given a binary tree, find the total number of leaf nodes it has.

Input

A binary tree.

Output

The total number of leaf nodes.

Sample input

Get hands-on with 1400+ tech skills courses.