#217
Contains Duplicate
easy· Arrays & Hashingruns: 0Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
sign in to paste and practice your own solution
wpm 0acc 100%time 0:000 / 218
class Solution:
def hasDuplicate(self, nums: list[int]) -> bool:
seen = set()
for num in nums:
if num in seen:
return True
seen.add(num)
return False
click the box to focus · tab inserts 4 spaces · backspace to correct · esc to pause
desktop only
codedrill is a typing game and needs a real keyboard. open this on a laptop or desktop to practice.
you can still browse problems and sections from your phone.