Complete the code to sort the input array before processing.
Array.[1](nums);Sorting the array helps to use two pointers efficiently and avoid duplicates.
Complete the code to skip duplicate elements for the first pointer.
if (i > 0 && nums[i] == nums[[1]]) continue;
We skip the current element if it is the same as the previous one to avoid duplicate triplets.
Fix the error in the while loop condition to move the left pointer correctly.
while (left < right && nums[left] == nums[[1]]) left++;
We compare the current left element with the next left element to skip duplicates after moving left pointer.
Fill both blanks to correctly move the right pointer and skip duplicates.
while (left < right && nums[right] == nums[[1]]) [2]--;
We compare the current right element with the previous right element (right - 1) and move the right pointer leftwards to skip duplicates.
Fill all three blanks to add the found triplet to the result list.
result.Add(new List<int> { nums[[1]], nums[[2]], nums[[3]] });The triplet consists of the elements at indices i, left, and right which sum to zero.
