Complete the code to initialize the left pointer at the start of the array.
int left = [1];The left pointer should start at index 0 to begin sorting from the start.
Complete the code to initialize the right pointer at the end of the array.
int right = [1] - 1;
The right pointer should start at the last index, which is size minus one.
Fix the error in the condition to move the current pointer forward when the element is 0.
if (nums[current] == 0) { std::swap(nums[current], nums[left]); left++; [1]++; }
After swapping with left, we must move current forward to continue scanning.
Fill both blanks to correctly swap and move pointers when the element is 2.
if (nums[current] == 2) { std::swap(nums[current], nums[[1]]); [2]--; }
Swap with right pointer and then move right pointer leftwards.
Fill all three blanks to complete the main while loop condition and pointer updates.
while ([1] <= [2]) { if (nums[current] == 0) { std::swap(nums[current], nums[left]); left++; current++; } else if (nums[current] == 2) { std::swap(nums[current], nums[right]); right--; } else { [3]++; } }
The loop runs while current is less than or equal to right. Increment current when element is 1.
