#K94902. Three Sum Triplet Finder

    ID: 38744 Type: Default 1000ms 256MiB

Three Sum Triplet Finder

Three Sum Triplet Finder

Given an array of integers and a target value, determine if there exist three distinct numbers in the list such that their sum equals the target. More formally, for an array lst of length N and a target integer T, you need to determine if there exist indices i, j, k (all distinct) such that

$$ a_i + a_j + a_k = T $$

Print Yes if such a triplet exists, otherwise print No.

inputFormat

The input is given from standard input and is formatted as follows:

  • The first line contains an integer T, the number of test cases.
  • For each test case:
    • The first line contains an integer N representing the number of elements in the list.
    • The second line contains N space‐separated integers.
    • The third line contains an integer representing the target sum.

outputFormat

For each test case, output a single line containing Yes if there exists a triplet in the array that sums to the target; otherwise, output No.

## sample
4
5
10 20 30 40 50
60
6
1 2 3 4 5 6
10
5
1 1 1 1 1
4
3
1000000000 -1000000000 0
0
Yes

Yes No Yes

</p>