Created
March 29, 2024 07:22
-
-
Save preston-56/7b173397156495872d6325f10b22e2e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def containsDuplicate(nums): | |
| num_set = set() | |
| for num in nums: | |
| if num in num_set: | |
| return True | |
| num_set.add(num) | |
| return False | |
| nums1 = [1,2,3,1] | |
| print(containsDuplicate(nums1)); # True | |
| nums2 = [1,2,3,4] | |
| print(containsDuplicate(nums2)); # False | |
| nums3 = [1,1,1,3,3,4,3,2,4,2] | |
| print(containsDuplicate(nums3)) # True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment