#K53757. Pair with Target Sum
Pair with Target Sum
Pair with Target Sum
Given an array of integers, determine if there exists a pair of distinct elements whose sum equals a given target.
Formally, for an array \(a_1, a_2, \dots, a_n\) and a target \(T\), find two indices \(i\) and \(j\) with \(i \neq j\) such that:
\(a_i + a_j = T\)
If such a pair exists, output Yes
; otherwise, output No
.
inputFormat
The first line contains two integers \(n\) and \(T\) where \(n\) is the number of elements in the array and \(T\) is the target sum.
The second line contains \(n\) space-separated integers, representing the array elements.
outputFormat
Output a single line: Yes
if there exists a pair of distinct elements whose sum equals \(T\), otherwise output No
.
5 14
1 2 3 9 11
Yes