All Tracks Data Structures Hash Tables Basics of Hash Tables Problem

Pair Sums
/
No tags
Problem
Editorial
Analytics

You have been given an integer array A and a number K. Now, you need to find out whether any two different elements of the array A sum to the number K. Two elements are considered to be different if they lie at different positions in the array. If there exists such a pair of numbers, print "YES" (without quotes), else print "NO" without quotes.

Input Format:

The first line consists of two integers N, denoting the size of array A and K. The next line consists of N space separated integers denoting the elements of the array A.

Output Format:

Print the required answer on a single line.

Constraints:

\( 1 \le N \le 10^6 \)

\( 1 \le K \le 2*10^6 \)

\( 1 \le A[i] \le 10^6 \)

SAMPLE INPUT
5 9
1 2 3 4 5
SAMPLE OUTPUT
YES
Explanation

Here, \(A[4] + A[5] = 4 + 5 = 9\). So, the answer is YES.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

Initializing Code Editor...
Notifications
View All Notifications

?