#C10394. Three Sum Problem
Three Sum Problem
Three Sum Problem
Given an array of integers, your task is to find all unique triplets \((a, b, c)\) such that \(a + b + c = 0\). A triplet is considered unique if there is no other triplet with the same set of values regardless of order.
The input begins with an integer \(N\) representing the number of elements in the array, followed by \(N\) space-separated integers. If one or more triplets exist, output each triplet in a separate line in the form a b c
in the order they are found using an efficient algorithm. If no such triplets are found, output exactly "No triplets found".
inputFormat
The first line contains an integer \(N\) denoting the number of elements. The second line contains \(N\) space-separated integers representing the array elements.
outputFormat
If triplets exist, print each unique triplet on a new line with each number separated by a single space. If no valid triplet exists, output a single line with the text "No triplets found".
## sample6
-1 0 1 2 -1 -4
-1 -1 2
-1 0 1
</p>