Same Direction Pointers
A reader scans ahead while a writer lags, compacting the array in place.
Two Pointers: Remove duplicates
1 equals the last kept value, so it is skipped. The writer stays put.
Cost
- Best
- O(n)
- Average
- O(n)
- Worst
- O(n)
- Space
- O(1)
Before this
Leads to
Topics that need this one first.
Taught by the same lesson
Two Pointers covers these too, in the same run.