Question bank › Two Pointers
Dsa Two Pointers Easy

The Wide Range Pair

Given a sorted array of N integers, find the maximum possible distance between two indices i and j (where i < j) such that their sum A[i] + A[j] falls within the inclusive range [Low, High]. Input Format: Line 1: N, Low, High Line 2: N sorted integers Example: Input: 5 7 10 1 2 5 8 12 Output: 3 Explanation: Pairs with sums in [7, 10] are (1, 8) sum 9 dist 3; (2, 8) sum 10 dist 2; (2, 5) sum 7 dist 1. Max distance is 3.

Key concepts

two_pointerssorted_arrays

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.