Matching Pairs

Imagine grouping numbers into pairs where both values in each pair must be the same. Write a function divide_array that receives a list of 2n numbers. Return True if all numbers can be split into equal-value pairs. If any number is left without a matching partner, return False.

Примеры

Ввод
[3, 2, 3, 2, 2, 2]
Вывод
True
Ввод
[1, 2, 3, 4]
Вывод
False
Ввод
[1, 1]
Вывод
True

Нужно реализовать

def divide_array(nums: list[int]) -> bool:

Теги

arrayhashmapdict
PostgreSQLv16

Taispeánfar toradh do chóid anseo

Visible tests
1
Input
[3,2,3,2,2,2]
ExpectedTrue
2
Input
[1,2,3,4]
ExpectedFalse
3
Input
[1,1]
ExpectedTrue
4
Input
[1,1,2,2,3,3]
ExpectedTrue
5
Input
[1,1,1,2]
ExpectedFalse
6
Input
[5,5,5,5]
ExpectedTrue
Focus radio
Paused · SomaFM · Fluid