Search⌘ K

Solved Problem - Pair Sum

Explore how to solve the pair sum problem efficiently using the two-pointer technique. This lesson helps you understand and implement a linear time solution for finding pairs in sorted arrays, enhancing your skills for competitive programming contests.

Problem statement

Given a sorted array of NN integers A[]A[]. Find if there exist a pair of integers A[i]A[i] and A[j]A[j] such that the sum is equal to the given integer XX.

Input format

The first line of input consists of two space-separated integers N(1N105)N(1 \leq N \leq 10^{5}) and X(1X106)X(1 \leq X \leq 10^{6}) ...