#C11344. Two Sum Existence
Two Sum Existence
Two Sum Existence
Given an array of integers and a target integer \(T\), determine if there exist two distinct indices \(i\) and \(j\) in the array such that \(a_i + a_j = T\). This problem is a classical two-sum problem often solved using hashing or two-pointer techniques. In this task, you are to process multiple test cases.
Constraints:
- \(1 \leq T \leq 10^5\) (number of test cases overall could vary)
- \(1 \leq n \leq 10^5\) for each test case
- \(-10^9 \leq a_i \leq 10^9\)
- The target \(T\) for each test case is an integer.
Input Format and Output Format are described below.
inputFormat
The input is given via standard input (stdin). The first line contains a single integer \(T\), the number of test cases. For each test case, the first line contains two space-separated integers \(n\) (the size of the array) and \(target\) (the target sum). The second line contains \(n\) space-separated integers representing the array.
outputFormat
For each test case, output a single line containing either "YES" if there exists a pair of distinct elements whose sum equals the target, or "NO" otherwise. The outputs for different test cases should be printed on separate lines in the order of the input test cases.
## sample1
4 9
2 7 11 15
YES
</p>