Question bank › Binary Search Tree
Dsa Binary Search Tree Medium

The Shadow Gap

You are given a set of unique timestamps representing when a shadow passes over a solar sensor. These are stored in a BST. Given a time range [L, R], find the maximum gap (difference) between any two consecutive sensor readings that fall within that range. If fewer than two readings exist in the range, return 0. Input: First line contains BST nodes. Second line contains two integers L and R. Output: The largest gap between consecutive nodes in [L, R]. Example: Input: 20 10 30 5 15 25 35 12 32 Output: 5 Explanation: Nodes in range [12, 32] are 15, 20, 25, 30. Gaps are: (20-15)=5, (25-20)=5, (30-25)=5. Max is 5.

Key concepts

binary_search_treerange_queryinorder_traversal

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.