Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the slow pointer at the start of the array.
DSA C
int slow = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Starting slow pointer at 1 instead of 0.
Using negative or out-of-bound indices.
✗ Incorrect
The slow pointer starts at index 0 to track the position of unique elements.
2fill in blank
mediumComplete the code to move the fast pointer through the array.
DSA C
for (int fast = [1]; fast < n; fast++) {
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Starting fast pointer at 0 causing redundant comparisons.
Starting fast pointer at n causing out-of-bound errors.
✗ Incorrect
The fast pointer starts at 1 to compare with the slow pointer at 0.
3fill in blank
hardFix the error in the condition to check if current element is different from last unique element.
DSA C
if (nums[fast] [1] nums[slow]) {
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '!=' causing no duplicates to be removed.
Using '<=' or '>=' causing incorrect comparisons.
✗ Incorrect
We check if the current element is not equal to the last unique element to identify duplicates.
4fill in blank
hardFill both blanks to update the slow pointer and assign the new unique element.
DSA C
slow[1]; nums[slow] = nums[2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Decrementing slow pointer instead of incrementing.
Assigning nums[slow] to itself instead of nums[fast].
✗ Incorrect
We increment slow by 1 and assign nums[fast] to nums[slow] to keep unique elements.
5fill in blank
hardFill in the blanks to return the count of unique elements after processing.
DSA C
return slow [1] [2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Returning slow without adding 1 causing off-by-one error.
Subtracting 1 causing wrong count.
Adding 0 which does not change the value.
✗ Incorrect
We return slow + 1 because slow is index-based, and adding 1 gives the count.
