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 Rust
let mut slow = [1];Attempts:
3 left
💡 Hint
Common Mistakes
Starting slow pointer at 1 instead of 0.
Using array length as starting index.
Using negative index which is invalid.
✗ Incorrect
The slow pointer starts at index 0 to track the position of unique elements.
2fill in blank
mediumComplete the code to loop through the array starting from the second element.
DSA Rust
for fast in [1]..arr.len() {
Attempts:
3 left
💡 Hint
Common Mistakes
Starting loop at 0 causing redundant comparison.
Starting loop at 2 skipping elements.
Using arr.len() - 1 which misses last element.
✗ Incorrect
The fast pointer starts from index 1 to compare with the slow pointer at index 0.
3fill in blank
hardFix the error in the condition to check if current element is different from last unique element.
DSA Rust
if arr[fast] [1] arr[slow] {
Attempts:
3 left
💡 Hint
Common Mistakes
Using == which checks for equality instead of difference.
Using >= or <= which are not correct for duplicate detection.
✗ 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 Rust
slow = slow [1] 1; arr[slow] = arr[[2]];
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction or multiplication instead of addition.
Assigning arr[slow] to arr[fast] instead of arr[fast] to arr[slow].
✗ Incorrect
We increment slow by 1 and assign the current fast element to arr[slow].
5fill in blank
hardFill all three blanks to return the length of unique elements after processing.
DSA Rust
return [1] + [2] - [3];
Attempts:
3 left
💡 Hint
Common Mistakes
Returning slow without adding 1.
Using fast instead of slow for length.
Subtracting 1 which is incorrect.
✗ Incorrect
The length of unique elements is slow + 1 because slow is index-based starting at 0.
