#THRSUM. ZERO TRIPLET
ZERO TRIPLET
The general elections are coming and so Rahul and Modi have started the preparations. An astrologer predicted that whoever solves the given problem first will win the elections.
The problem is as follows: Given an array nums
of n integers, are there elements a, b, c in nums
such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
As I want modi to win, so you have to solve this problem for Modi before Rahul does...Good Luck
Input
In the first line ,you will be given t the number of test cases ,for each test case you will be given n, the size of the array. In the next line you will be given n space separated elements of the array.
Input constraints :t<=10000, n<=10000 (sum of n over all test cases won't exceed 10^8)
Output
Output the number of such triplets and subsequently print each of the triplets in a separate line in lexicographic order.
Example
Input:
2
5
-1 0 1 2 -1
3
0 0 0
Output:
2
-1 -1 2
-1 0 1
1
0 0 0