← Back

Remove duplicates from a sorted array.

Given a sorted array of integers, remove duplicates in-place.

Algorithm

  1. Initialize a pointer for the last unique element.
  2. Iterate through the array:
  3. Return or print the values.

Time Complexity

The time complexity of this algorithm is O(n), where n is the number of elements in the array.