#K64687. Three Sum Triplets
Three Sum Triplets
Three Sum Triplets
Given a list of n integers and a target value, determine whether there exist three distinct elements (with different indices) in the list whose sum equals the target. If such a triplet exists, output the three integers in increasing order. Otherwise, output -1.
This condition can be expressed using the formula: $$a+b+c=\text{target}$$, where \(a\), \(b\), and \(c\) are three different elements from the array.
inputFormat
The input is given via standard input (stdin). The first line contains two space-separated integers: n (the number of elements) and target. The second line contains n space-separated integers representing the elements of the array.
outputFormat
Print three space-separated integers in increasing order if a valid triplet exists. If no such triplet exists, print -1.## sample
6 12
1 2 3 4 5 6
1 5 6