#K46437. Pair Sum Problem
Pair Sum Problem
Pair Sum Problem
You are given an array of integers and a target integer. Your task is to determine whether there exists a pair of distinct elements in the array whose sum is equal to the target. In other words, you need to check if there exist indices and such that and $$a_i + a_j = \text{target}.$$ If such a pair exists, print Yes
; otherwise, print No
.
Note: The array may be empty or contain negative numbers.
inputFormat
The first line of input contains an integer representing the number of elements in the array. The second line contains space-separated integers representing the array elements. The third line contains an integer representing the target sum.
outputFormat
Output a single line with Yes
if there exists a pair of distinct elements whose sum is equal to the target, and No
otherwise.## sample
5
2 7 11 15 3
9
Yes