#C3784. Find Unique Triplets Summing to Target
Find Unique Triplets Summing to Target
Find Unique Triplets Summing to Target
Given an array of integers, your task is to find all unique triplets that sum to a given target value T. Each triplet (a, b, c) must satisfy the equation $a + b + c = T$, and the triplets should be output in lexicographically sorted order with no duplicates.
Note: Use an efficient two-pointer technique after sorting the array to reduce the overall time complexity.
inputFormat
The first line contains two integers n and T separated by a space, where n is the number of elements in the array and T is the target sum.
The second line contains n integers separated by spaces, representing the array elements.
outputFormat
Output each unique triplet on a separate line. The numbers within a triplet should be separated by a space. If no triplet exists, output nothing.
## sample6 0
-1 0 1 2 -1 -4
-1 -1 2
-1 0 1
</p>