Example with duplicates
Input
remove_duplicates([1, 1, 2])
Output
2
The unique elements are [1, 2], so the function returns 2.
Full lesson preview
Remove duplicates in-place from a sorted array and return the count of unique elements.
Problem statement
Task
Examples
Input
remove_duplicates([1, 1, 2])
Output
2
The unique elements are [1, 2], so the function returns 2.
Input format
Output format
Constraints
Samples
Input
remove_duplicates([0, 0, 1, 1, 1, 2, 2, 3, 3, 4])
Output
5
Unique elements are [0,1,2,3,4], so the returned length is 5.