Challenge: Number of Full Nodes in a Binary Tree

Let’s count the number of full nodes in a binary tree.

Problem

Given a binary tree, find the count of full nodes in it. A full node has non-null left and right children.

Input

A binary tree.

Output

The number of full nodes.

Sample input

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