#C2512. Unique Three Sum Problem
Unique Three Sum Problem
Unique Three Sum Problem
You are given an array of integers and your task is to find all unique triplets \( (a, b, c) \) such that their sum equals zero, i.e. \(a+b+c=0\). The triplets should not contain duplicates and must be sorted in lexicographical order.
Note: Two triplets are considered the same if they contain the same three integers irrespective of the order.
inputFormat
The input is read from standard input (stdin) and has the following format:
n num1 num2 num3 ... numn
Here, n
denotes the number of elements in the array, followed by n
integers separated by spaces.
outputFormat
Output the unique triplets that sum to zero, one triplet per line. Each triplet should be printed as three space-separated integers. The triplets must be printed in lexicographical order. If no triplet exists, print nothing.
## sample6
-1 0 1 2 -1 -4
-1 -1 2
-1 0 1
</p>