Question bank › Recursion
Dsa Recursion Warm-up

Binary Tree Leaf Count

You have to count the number of leaf nodes in a binary tree represented as a nested list. A leaf node is defined as a node that has no children. Input Format: A nested list representation of a binary tree. Each node is represented as a list where the first element is the value and the second and third elements are children (left, right). If a node has no children, those positions will be None. Output Format: An integer representing the number of leaf nodes in the binary tree. Example: Input: [1, [2, [4, None, None], [5, None, None]], [3, None, None]] Output: 3

Key concepts

recursionbinary treescounting

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 InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.