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

Count Nodes in a Range in BST

You are given the root of a binary search tree (BST), along with two integers low and high. Your task is to count how many nodes have values between low and high (inclusive). Input Format: - The first line contains an integer n, the number of nodes in the BST. - The next n lines each contain a single integer, which represents the value of the node inserted into the BST. - The last line contains two integers, low and high. Output Format: - Print a single integer: the count of nodes in the specified range. Example: Input: 5 10 5 15 3 7 5 Output: 4

Key concepts

binary_search_treerange_query

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.