Duplicate Check
Given a list of integers nums, check whether any number appears more than once. This is useful when you need to quickly spot duplicate data, such as repeated IDs or duplicate requests. Return True if there is at least one duplicate, otherwise return False.
Примеры
Ввод
[1, 2, 3, 1]Вывод
TrueВвод
[1, 2, 3, 4]Вывод
FalseВвод
[]Вывод
FalseНужно реализовать
def contains_duplicate(nums: list[int]) -> bool:
Теги
arrayhashmap
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
[]Expected
False4
Input
[1,2,3,1,1,2]Expected
True5
Input
[1,2,3]Expected
False6
Input
[1,1,2,3]Expected
TrueFocus radio
Paused · SomaFM · Fluid