Given an array and a value, find all the triplets in the array whose sum is equal to the given value. For example, if the given array is
{12, 3, 4, 1, 6, 9}and the given sum is24, then this is one triplet(12, 3 and 9)which contributes to the total sum of 24.
Solution for given example:
6, 9, 9
6, 6, 12
3, 9, 12
Conditions:
The ordering of the numbers in the solution does not matter.
Duplicate triplet is not allowed.
A number is not allowed to be used multiple times.