Deduplicate a sorted array
Removing duplicates from a sorted array can be done in:
Show hints (2)+
- The array is already sorted — duplicates are adjacent.
- Compare each element with the previous one.
Answer
Reveal answer →Final answer
O(n) time, O(1) extra space
Want the full step-by-step worked solution? It's part of Premium — along with a worked solution for every question in the bank.