Question bank › Two Pointers
Dsa Two Pointers Easy

Proximity Alerts

A social distancing app logs the positions of people on a linear path (sorted). The app needs to count how many pairs of people (i, j) where i < j are within a 'caution zone' range. A pair is in the caution zone if the distance between them is at least D_MIN and at most D_MAX. Input Format: Line 1: Two integers D_MIN and D_MAX. Line 2: A space-separated list of sorted integers representing positions. Output Format: A single integer representing the total number of pairs. Example: Input: 15 25 10 20 30 40 Output: 2 (Explanation: Pairs are (10, 30) distance 20, and (20, 40) distance 20.)

Key concepts

two_pointersrange_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.