Given a sorted array, remove duplicates in place so each unique value appears once, and return the count of unique values — the first part of the array up to that count holds the result.
Example 1
Explanation: The first 2 slots of the mutated array hold the unique values 1 and 2, in order; anything after index 1 is irrelevant.
Example 2
Explanation: Five distinct values exist; the first five slots hold them in ascending order.
Example 3
Explanation: A single-element array is trivially already unique.
How would the write-pointer condition need to change if each distinct value were allowed to appear at most twice instead of once?
Code execution is coming soon.