Given an array A, find all unique triplets in the array whose sum is equal to zero.
A: [1, 1, 0, -1, -2]
Triplets: [
[-2, 1, 1],
[-1, 0, 1]
]
Note: Each triplet should be sorted. The resultant array should be sorted as well.
The first line contains an integer ‘T’ denoting the number of test cases.
For each test case, the input contains two lines:
For each test case, the output contains the following lines.
2
4
-1 0 1 2
5
1 -1 9 -8 0
1
-1 0 1
2
-8 -1 9
-1 0 1
1 <= T <= 10
3 <= n <= 3000
-105 <= Ai <= 105