#K35687. Two Sum Exists
Two Sum Exists
Two Sum Exists
You are given t test cases. For each test case, you are given an array of integers and a target integer \(x\). Your task is to determine whether there exist two distinct elements in the array whose sum is exactly \(x\). If such a pair exists, output True
; otherwise, output False
.
Each test case is provided in the following format:
- An integer n representing the size of the array.
- A line containing n space-separated integers.
- An integer x representing the target sum.
The first line of the input contains an integer t, indicating the number of test cases.
inputFormat
The input begins with an integer t, which denotes the number of test cases. For each test case, the input consists of three lines:
- An integer n representing the number of elements in the array.
- A line with n space-separated integers denoting the elements of the array.
- An integer x, the target sum.
outputFormat
For each test case, output a single line containing either "True" if there exists a pair of distinct elements whose sum equals x, or "False" otherwise.## sample
3
5
1 2 3 4 5
9
4
2 10 5 9
8
6
3 7 1 5 2 8
10
True
False
True
</p>