Bird
0
0
DSA Cprogramming~10 mins

Remove Duplicates from Sorted Array Two Pointer in DSA C - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A0
B1
C-1
Dn
Attempts:
3 left
💡 Hint
Common Mistakes
Starting slow pointer at 1 instead of 0.
Using negative or out-of-bound indices.
2fill in blank
medium

Complete 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'
A-1
B1
Cn
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Starting fast pointer at 0 causing redundant comparisons.
Starting fast pointer at n causing out-of-bound errors.
3fill in blank
hard

Fix 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'
A>=
B<=
C!=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '!=' causing no duplicates to be removed.
Using '<=' or '>=' causing incorrect comparisons.
4fill in blank
hard

Fill 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'
A++
B--
C[fast]
D[slow]
Attempts:
3 left
💡 Hint
Common Mistakes
Decrementing slow pointer instead of incrementing.
Assigning nums[slow] to itself instead of nums[fast].
5fill in blank
hard

Fill 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'
A+
B-
C1
D0
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.