Repeat Detector
When checking data, you often need to quickly tell whether any value appears more than once. Given a list nums, return True if at least one value is duplicated. If all elements are unique or the list is empty, return False. The solution should run in O(n) time.
Примеры
Ввод
[1, 2, 3, 1]Вывод
TrueВвод
[1, 2, 3, 4]Вывод
FalseВвод
[]Вывод
FalseНужно реализовать
def contains_duplicate(nums: list[int]) -> bool:
Теги
sethashmaparray
Συνδεθείτε για να δείτε το ιστορικό υποβολών
ΣύνδεσηΣυνδεθείτε για να χρησιμοποιήσετε τον AI Mentor
ΣύνδεσηVisible tests
1
Input
[1,2,3,1]Expected
True2
Input
[1,2,3,4]Expected
False3
Input
[]Expected
False4
Input
[1,1,1,3,3,4,3,2,4,2]Expected
True5
Input
[5]Expected
False6
Input
[2,3,4,5]Expected
FalseFocus radio
Paused · SomaFM · Fluid