Count leaf nodes in a binary tree

2.5

2 votes
Easy-Medium
Problem

A node is a leaf node if both left and right child nodes of it are NULL.

enter image description here

Leaf count for the above tree is 3.

INPUT: First line No of Nodes(excluding Root) Second line Consists Tree Nodes in level order traversal.

Output :

Output Should Be No. of Leaf Nodes.

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

Input tree shown in fig enter image description here

Editor Image

?