Find triplets with zero sum (3Sum Problem). Given an array of integers, write a code to find all unique triplets in the array which gives the sum of zero.
Note: The solution set must not contain duplicate triplets.
For example –
Example 1:
Input: {-1, 0, 1, 2, -1, -4}
Output: {-1, 0, 1}, {-1, -1, 2}
Example 2:
Input: {-8, -7, 5, 2}
Output: {-7, 5, 2}