#C6253. Three Sum Challenge
Three Sum Challenge
Three Sum Challenge
You are given a list of non-negative integers and a target value \(T\). Your task is to determine whether there exist three distinct indices \(i, j, k\) such that \(nums[i] + nums[j] + nums[k] = T\). If such a triplet exists, print "YES"; otherwise, print "NO".
Note: Each test case will be given as input from standard input (stdin) and the result should be output to standard output (stdout).
inputFormat
The input format is as follows:
- The first line contains an integer \(n\) representing the number of elements in the array.
- The second line contains \(n\) space-separated non-negative integers representing the array elements.
- The third line contains a single integer representing the target value \(T\).
outputFormat
Output a single line containing "YES" if there exists any triplet (with distinct indices) such that the sum of the three numbers equals \(T\); otherwise, output "NO".
## sample5
1 2 3 4 5
9
YES
</p>