#K2476. Pair Sum Finder
Pair Sum Finder
Pair Sum Finder
You are given an array of n integers and a target sum \(K\). Your task is to determine whether there exists a pair of distinct elements in the array whose sum equals \(K\). Formally, given an array \(A[0 \dots n-1]\), you need to check if there exist indices \(i\) and \(j\) such that \(i < j\) and
[ A[i] + A[j] = K ]
If such a pair exists, output YES
. Otherwise, output NO
for that test case.
Note: Each test case is independent.
inputFormat
The first line of input contains an integer \(T\) which denotes the number of test cases. For each test case, the input is as follows:
- The first line contains two space-separated integers \(n\) and \(K\), where \(n\) is the number of elements in the array and \(K\) is the target sum.
- The second line contains \(n\) space-separated integers representing the elements of the array.
outputFormat
For each test case, print a single line containing YES
if there exists a pair of distinct elements in the array that sum to \(K\), otherwise print NO
.
1
3 10
1 2 3
NO
</p>