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
PostgreSQLv16

Tady se objeví výsledek běhu kódu

Visible tests
1
Input
[1,1,2]
Expected2
2
Input
[0,0,1,1,1,2,2,3,3,4]
Expected5
3
Input
[]
Expected0
4
Input
[1]
Expected1
5
Input
[1,2,3,4]
Expected4
6
Input
[2]
Expected1
Focus radio
Paused · SomaFM · Fluid