Given an array of integers and a target sum, find all unique triplets in the array that sum up to the target value. The challenge is to handle duplicates efficiently and consider various edge cases.
For array [-1, 0, 1, 2, -1, -4] and targetSum = 0:
Implement the solve method to find all unique triplets that sum to the target value. Consider using techniques like sorting and two-pointer approach for efficiency.
Found two unique triplets that sum to zero
Single triplet using three 1s from the array
Single triplet of zeros, duplicates handled