Practice · 1 of 5
Sorted Pair Sum
CHALLENGE
Difficulty: intermediate+25 XP
**Description:** In a sorted array of n integers, decide whether two elements at
DIFFERENT positions sum exactly to S.
**Input:** Line 1: n S (2 <= n <= 200000, |S| <= 10^18). Line 2: n sorted integers
(|a[i]| <= 10^9).
**Output:** Print YES if such a pair exists, otherwise NO.
**Example:** 5 9 / 1 2 4 7 11 -> YES (2 + 7).
Press Submit to check your solution.
Back to lesson: Practice: Two Pointers Problem Set