Complete the code to initialize the left pointer to 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 to the end of the array.
int right = [1] - 1;
The right pointer should start at the last index, which is n - 1.
Fix the error in the while loop condition to process elements correctly.
while ([1]) {
The loop should continue while i is less than or equal to right to cover all elements.
Fill both blanks to swap elements and update pointers correctly when nums[i] is 0.
if (nums[i] == 0) { swap(nums, i, [1]); i++; [2]++; }
Swap with left pointer and then increment both i and left to move forward.
Fill all three blanks to swap elements and update pointers correctly when nums[i] is 2.
else if (nums[i] == 2) { swap(nums, i, [1]); [2]--; [3] = [3]; }
Swap with right pointer, decrement right, and keep i same to recheck swapped element.
