#K66407. Three Sum to Target

    ID: 32413 Type: Default 1000ms 256MiB

Three Sum to Target

Three Sum to Target

Given an array of integers (nums) and an integer (target), determine if there exist three distinct elements in (nums) whose sum is exactly (target).

Your task is to output "Yes" if there exists a triplet ((a, b, c)) such that (a + b + c = target) where each element comes from a different position in the array, and "No" otherwise.

inputFormat

Input is read from standard input (stdin). The first line contains two integers (n) and (target), where (n) is the number of elements in the array. The second line contains (n) space-separated integers representing the array (nums).

outputFormat

Output to standard output (stdout) a single line with either "Yes" or "No", indicating whether there exists a triplet in (nums) whose sum equals (target).## sample

5 9
1 2 3 4 5
Yes