Question bank › Binary Search Tree
Dsa Binary Search Tree Warm-up

Count Leaves

Given a binary search tree represented as a series of space-separated integers (the level-order traversal of the BST), write a program to count and return the number of leaf nodes present in it. A leaf node is defined as a node with no child nodes. Input format: - The first line contains space-separated integers representing the level-order traversal of the BST. Output format: - Print a single integer which is the count of leaf nodes. Example: Input: 10 5 15 3 7 12 20 Output: 4

Key concepts

binary_search_treeleavestree_structure

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.