#C3411. Three Sum Problem
Three Sum Problem
Three Sum Problem
Given an array of integers and a target integer, determine whether there exist three distinct elements in the array that sum up exactly to the target. In other words, determine if there exist indices \(i, j, k\) (all distinct) such that:
\(a_i + a_j + a_k = \text{target}\)
If such a triplet exists, output True
; otherwise, output False
.
inputFormat
The 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.
outputFormat
Output to standard output (stdout) a single boolean value: True
if there exists a triplet of distinct indices such that their corresponding elements sum to (target), and False
otherwise.## sample
6 2
-1 2 3 0 -4 1
True