Skip to content
CampusEduX

Count Leaf Nodes

Easyjavapythonccppjavascript

Count the number of nodes in a binary tree that have no children.

Input Format

The first line contains an integer M, the number of level-order tokens. The second line contains M space-separated tokens (integers or null). It is blank when M is 0.

Output Format

Print the number of leaf nodes.

Related Problems

  • Inorder Traversal
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Preorder Traversal
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Postorder Traversal
    Easy · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...