summaryrefslogtreecommitdiff
path: root/1_array_hashing
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2024-08-25 16:27:25 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2024-08-25 16:27:25 +0900
commit1215bb5e073f7718539a8033514673128c654fe9 (patch)
tree73cdd44ff49fe57bf983a770e5648d06063882b8 /1_array_hashing
parent6666388bbfc5f66756464151ff894a76a25c4ebb (diff)
Init
Diffstat (limited to '1_array_hashing')
-rw-r--r--1_array_hashing/contains_duplicate.py10
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