Remove Duplicates In Place
Use a slow and fast pointer pair.
Drop Duplicates In Place
Given a sorted array, keep one copy of each value using no extra array. Doing it in place saves memory and is a classic interview ask. 🧹
Why Sorted Helps
When the array is sorted, every duplicate sits right next to its twin. So you only ever compare neighbors, never the whole array.
All lessons in this course
- Two Pointers on a Sorted Array
- Find a Pair with a Given Sum
- Remove Duplicates In Place
- Merge Two Sorted Sequences