Remove Duplicates from Sorted Array
The writer only copies a value that differs from the last one it kept.
Two Pointers: Remove duplicates
2 is different from the last kept value 1, so it is written at index 1.
Cost
- Best
- O(n)
- Average
- O(n)
- Worst
- O(n)
- Space
- O(1)
Before this
Taught by the same lesson
Two Pointers covers these too, in the same run.