Duplicate Check

When checking data, you often need to quickly know whether a list contains repeated values. Given nums, return True if at least one number appears more than once. If all elements are distinct, return False. An empty list also has no duplicates.

Примеры

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

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

def contains_duplicate(nums):

Теги

arraysethashmap
PostgreSQLv16

Tutaj pojawi się wynik wykonania kodu

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