#C6102. Three Sum Problem
Three Sum Problem
Three Sum Problem
Given an array of integers, find all unique triplets \( [nums[i], nums[j], nums[k]] \) such that \( nums[i] + nums[j] + nums[k] = 0 \) and \( i\), \( j\), \( k \) are distinct. The solution set must not contain duplicate triplets. Your program should read input from stdin and output the answer to stdout.
Note: Use an efficient algorithm (such as sorting with two pointers) to handle larger inputs.
inputFormat
The first line contains an integer \( n \) representing the number of elements in the array. The second line contains \( n \) space-separated integers.
outputFormat
For each unique triplet that sums to zero, print a line in the format: [a, b, c]
.
If no such triplets exist, output nothing.
## sample6
-1 0 1 2 -1 -4
[-1, -1, 2]
[-1, 0, 1]
</p>