Question bank › Two Pointers
Dsa Two Pointers Easy

Maximum Coverage Area

You are installing a wide-angle security sensor that covers a continuous range of length L. Given a sorted list of house coordinates on a single road, find the maximum number of houses that can be covered by the sensor simultaneously if you can place the starting point of the sensor anywhere. Input Format: Line 1: Two integers N and L, the number of houses and the length of the sensor coverage. Line 2: N space-separated integers representing the sorted coordinates of the houses. Output Format: A single integer representing the maximum number of houses covered. Example: Input: 5 10 1 5 8 12 20 Output: 3 (Explanation: A sensor from coordinate 1 to 11 covers houses at 1, 5, and 8.)

Key concepts

two_pointerssliding_window

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.