Skip to content

Commit

Permalink
contains duplicate solution
Browse files Browse the repository at this point in the history
  • Loading branch information
EstherKim97 committed Dec 13, 2024
1 parent 8901b1d commit 63dac45
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions contains-duplicate/EstherKim97.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

def containsDuplicate(nums):
seen = set()
for num in nums:
if num in seen:
return True
seen.add(num)
return False

0 comments on commit 63dac45

Please sign in to comment.