#K45092. Three Sum Problem
Three Sum Problem
Three Sum Problem
Given an array of integers, find all unique triplets ( (a, b, c) ) such that ( a + b + c = 0 ). Each triplet must be output in non-decreasing order, and the overall list of triplets should be sorted in lexicographical order. This problem tests your ability to efficiently implement the two-pointer technique and handle duplicate elements.
inputFormat
The input is given via stdin. The first line contains an integer (N), the number of elements in the array. The second line contains (N) space-separated integers.
outputFormat
Output to stdout. The first line should contain an integer (M) indicating the number of unique triplets. The following (M) lines each contain three space-separated integers representing a triplet in non-decreasing order.## sample
6
-1 0 1 2 -1 -4
2
-1 -1 2
-1 0 1
</p>