summaryrefslogtreecommitdiff
path: root/1_array_hashing/contains_duplicate.py
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2024-08-25 01:01:55 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2024-08-25 01:01:55 +0900
commit6666388bbfc5f66756464151ff894a76a25c4ebb (patch)
treee9b85c5dbbf0efa00780d8c3df8ee2752bc8cfa5 /1_array_hashing/contains_duplicate.py
parentb6855458c3c74ee93496275ea97bc3ba97a31e07 (diff)
Init
Diffstat (limited to '1_array_hashing/contains_duplicate.py')
-rw-r--r--1_array_hashing/contains_duplicate.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/1_array_hashing/contains_duplicate.py b/1_array_hashing/contains_duplicate.py
index e437e4f..1410d4d 100644
--- a/1_array_hashing/contains_duplicate.py
+++ b/1_array_hashing/contains_duplicate.py
@@ -20,7 +20,6 @@ Input: nums = [1, 2, 3, 4]
Output: false
"""
-
from typing import List
@@ -35,7 +34,7 @@ class Solution:
# 3. hashset
def hashset(self, nums: List[int]) -> bool:
- hs = set()
+ hs: set = set()
for i in range(len(nums)):
if nums[i] in hs:
return True
@@ -70,6 +69,7 @@ space: O(1)
time: O(n)
space: O(n)
code:
+```python
class Solution:
def hasDuplicate(self, nums: List[int]) -> bool:
hashset = set()
@@ -79,4 +79,5 @@ class Solution:
return True
hashset.add(n)
return False
+```
"""