Given a sorted array, remove duplicates in-place so that each unique element appears once and return the new length. Since equal values are adjacent, a two-pointer overwrite strategy is enough.
nums = sorted array of integers
k, the number of unique elements
Example 1:
Input:
nums = [1,1,2]
Output:
2
Explanation:
The unique prefix becomes [1,2].
Example 2:
Input:
nums = [0,0,1,1,1,2,2,3,3,4]
Output:
5
Explanation:
The unique elements are [0,1,2,3,4].