diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2024-08-25 16:27:25 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2024-08-25 16:27:25 +0900 |
| commit | 1215bb5e073f7718539a8033514673128c654fe9 (patch) | |
| tree | 73cdd44ff49fe57bf983a770e5648d06063882b8 | |
| parent | 6666388bbfc5f66756464151ff894a76a25c4ebb (diff) | |
Init
| -rw-r--r-- | 1_array_hashing/contains_duplicate.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/1_array_hashing/contains_duplicate.py b/1_array_hashing/contains_duplicate.py index 1410d4d..ab100ea 100644 --- a/1_array_hashing/contains_duplicate.py +++ b/1_array_hashing/contains_duplicate.py @@ -20,7 +20,7 @@ Input: nums = [1, 2, 3, 4] Output: false """ -from typing import List +from typing import List, Set class Solution: @@ -34,11 +34,11 @@ class Solution: # 3. hashset def hashset(self, nums: List[int]) -> bool: - hs: set = set() - for i in range(len(nums)): - if nums[i] in hs: + hs: Set = set() + for _, n in enumerate(nums): + if n in hs: return True - hs.add(nums[i]) + hs.add(n) return False |
