
Input: ‘N’ = 5
'ARR' = [-1, -1, 2, 0, 1]
Output:
-1 -1 2
-1 0 1
Explanation:
(-1 -1 +2) = (-1 +0 +1) = 0.
The first line contains an integer, ‘N’, representing the number of elements in the array.
The next line contains ‘N’ space-separated integers representing the elements of the array.
Return an integer, the number of all the unique triplets with zero-sum.
The solution to the problem lies in first sorting the array, then we can apply the two pointers approach. The two pointers approach would be traversing the array from one side and then for the fixed element we can find other two elements using two pointers approach as the array is sorted now.