Skip to content

Commit 6fd573f

Browse files
committed
contains duplicate solution
1 parent 53ce7c7 commit 6fd573f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

contains-duplicate/Jiun-Shin.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# 시간 복잡도 : o(n) for loop
2+
# 공간 복잡도 o(1) hash map
3+
4+
class Solution:
5+
def containsDuplicate(self, nums: List[int]) -> bool:
6+
hashmap = {}
7+
8+
for i, n in enumerate(nums):
9+
if n in hashmap:
10+
return True
11+
hashmap[n] = i
12+
return False

0 commit comments

Comments
 (0)