Question bank › Trees
Dsa Trees Easy

Binary Tree Leaf Counter

You are given the root of a binary tree. Write a function to count the number of leaf nodes in the tree. A leaf node is a node that does not have any children. The input tree is given in a serialized format where each node value is separated by a space, and 'null' represents a nonexistent node. The first value in the input represents the root of the tree. Example: Input: 1 2 3 null null 4 5 Output: 3

Key concepts

treesrecursioncounting

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.