#C5189. Pair With Given Sum
Pair With Given Sum
Pair With Given Sum
Given an array of integers and a target integer \(T\), determine whether there exist two distinct elements in the array whose sum equals \(T\). Note that the two elements must be at different positions in the array, even if they have the same value. For example, if the array is [5, 5] and \(T = 10\), the answer is True.
The solution should be efficient (preferably \(O(n)\) on average) by using an appropriate data structure, such as a hash set, to check for the required complement.
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 "True" if there exist two distinct elements whose sum is equal to (T), otherwise output "False".## sample
4 8
1 2 3 9
False