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
Pieslēdzies, lai redzētu iesniegumu vēsturi
PieslēgtiesPieslēdzies, lai izmantotu AI mentoru
PieslēgtiesVisible tests
1
Input
[1,2,3,1]Expected
True2
Input
[1,2,3,4]Expected
False3
Input
[1,1,1,3,3,4,3,2,4,2]Expected
True4
Input
[]Expected
False5
Input
[5]Expected
False6
Input
[5,5]Expected
TrueFocus radio
Paused · SomaFM · Fluid