Complete the code to initialize the slow pointer at the start of the array.
int slow = [1];The slow pointer starts at index 0 to track the position of unique elements.
Complete the code to iterate through the array starting from the second element.
for (int fast = [1]; fast < nums.Length; fast++)
The fast pointer starts at index 1 to compare with the slow pointer at index 0.
Fix the error in the condition to check if current element is different from last unique element.
if (nums[fast] [1] nums[slow])
We want to check if the current element is different to identify a new unique element.
Fill both blanks to update the slow pointer and assign the new unique element.
slow[1]; nums[slow] = nums[2];
Increment slow pointer by 1 and assign the element at fast pointer to the slow pointer position.
Fill all three blanks to complete the method returning the count of unique elements.
public int RemoveDuplicates(int[] nums) {
if (nums.Length == 0) return [1];
int slow = [2];
for (int fast = 1; fast < nums.Length; fast++) {
if (nums[fast] != nums[slow]) {
slow[3];
nums[slow] = nums[fast];
}
}
return slow + 1;
}Return 0 if array is empty, start slow at 0, increment slow when unique element found.
