0026. Remove Duplicates from Sorted Array
Two Pointers — Interactive Step-by-Step Animation
Load
[0,0,1,1,1,2,2,3,3,4]
[1,1,2]
[1,1,1,1]
[1,2,3,4,5]
[-3,-1,0,0,2]
[1]
▶ Play
❚❚ Pause
Step →
Reset
Speed:
0.5x
1x
2x
4x
slow = 0
for fast = 1 to n-1:
if nums[fast] != nums[slow]:
slow++
nums[slow] = nums[fast]
return slow + 1
Press
Step
or
Play
to start the animation.
Array State:
Slow Pointer (write position)
0
Fast Pointer (scan position)
1
Unique Count (k)
-
Step
0
Log