Concept Flow - Three Sum Problem All Unique Triplets
Sort the array
Fix first element i
Set left = i+1, right = end
Calculate sum = nums[i
Add triplet
Move left and right skipping duplicates
Move left right to increase sum
Move right left to decrease sum
Repeat until left >= right
Move i to next unique element
Repeat until i reaches end
Return all unique triplets
We sort the array, then fix one element and use two pointers to find pairs that sum to zero with it, skipping duplicates to get unique triplets.
