Write a function to find the total number of leaf nodes in a binary tree. A node is described as a leaf node if it doesn't have any children. If there are no leaf nodes, return

`0`

.
Example: 1 / \ 2 3 / \ / \ 4 5 6 7 / \ 8 9 ==> no. of leaves = 5

Need a **hand?** Try out these hints, one at a time.

A recursive implementation is straightforward.

1. Recursively traverse the tree.

2. At each node, determine if its

2a. If

2b. Otherwise, find number of leaves in its left and right subtrees (recursively).

3. Return the sum of the number of leaves in the left and the right subtrees.

2. At each node, determine if its

`left`

and `right`

child nodes are `null`

.
2a. If

`true`

, return `1`

.
2b. Otherwise, find number of leaves in its left and right subtrees (recursively).

3. Return the sum of the number of leaves in the left and the right subtrees.

public int numberOfLeaves(TreeNode root) { }

**C**

**Java**

**Python**