#K13046. Pair Sum Finder
Pair Sum Finder
Pair Sum Finder
You are given an array of n integers and an integer k. Your task is to determine whether there exists a pair of distinct indices \(i\) and \(j\) such that
\(arr[i] + arr[j] = k\)
If such a pair exists, output Yes
, otherwise output No
.
Note: Each element in the array can be used at most once in forming the pair.
inputFormat
The first line contains two space-separated integers n and k.
The second line contains n space-separated integers representing the array elements.
\(1 \le n \le 10^5\) and each element together with k can be any integer that fits in the 32-bit signed integer range.
outputFormat
Output a single line containing either Yes
if there exists a pair of distinct elements whose sum equals k, or No
otherwise.
4 8
1 4 3 5
Yes