Sock Pairs
After laundry, socks need to be matched into pairs of the same color. The function sock_merchant receives the number of socks n and a list of colors ar, where equal numbers mean the same color. Count how many complete pairs can be made. A leftover sock without a pair does not count.
Примеры
Ввод
9, [10, 20, 20, 10, 10, 30, 50, 10, 20]Вывод
3Ввод
1, [1]Вывод
0Ввод
4, [1, 1, 1, 1]Вывод
2Нужно реализовать
def sock_merchant(n: int, ar: list[int]) -> int:
Теги
arraydicthashmap
Inicia sesión para ver tu historial de envíos
Iniciar sesiónInicia sesión para usar el AI Mentor
Iniciar sesiónVisible tests
1
Input
9, [10,20,20,10,10,30,50,10,20]Expected
32
Input
1, [1]Expected
03
Input
4, [1,1,1,1]Expected
24
Input
6, [1,1,2,2,2,2]Expected
35
Input
0, []Expected
06
Input
1000, [10,20,20,10,10,30,50,10,20,10]Expected
3Focus radio
Paused · SomaFM · Fluid