Count Unique Values
In a sorted list, equal numbers stand next to each other, so duplicates are easy to detect. Given a list nums, count how many unique elements remain if each repeated value is kept only once. Return that count.
Примеры
Ввод
[1, 1, 2]Вывод
2Ввод
[0, 0, 1, 1, 1, 2, 2, 3, 3, 4]Вывод
5Ввод
[]Вывод
0Нужно реализовать
def remove_duplicates(nums: list[int]) -> int:
Теги
arraytwo-pointers
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign inVisible tests
1
Input
[1,1,2]Expected
22
Input
[0,0,1,1,1,2,2,3,3,4]Expected
53
Input
[]Expected
04
Input
[1]Expected
15
Input
[1,2,3,4]Expected
46
Input
[2]Expected
1Focus radio
Paused · SomaFM · Fluid