#C10155. Find Pair with Target Sum
Find Pair with Target Sum
Find Pair with Target Sum
Given an array of n integers and an integer target \(T\), determine whether there exists a pair of distinct elements in the array whose sum is exactly equal to \(T\). If such a pair exists, output 1
; otherwise, output 0
. This problem tests your understanding of efficient search techniques and hash-based data structures.
For example, if the input array is [2, 7, 11, 15] and \(T = 9\), the pair (2, 7) sums up to 9, so the output is 1
.
inputFormat
The first line contains an integer \(n\) representing the number of elements in the array.
The second line contains \(n\) space-separated integers representing the array elements.
The third line contains an integer \(T\), the target sum.
outputFormat
Output a single integer: 1
if there exists a pair of distinct elements whose sum equals \(T\), and 0
otherwise.
4
2 7 11 15
9
1