Skip to content

Commit 8f7a714

Browse files
committed
풀이법 추가
1 parent af8f483 commit 8f7a714

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

contains-duplicate/jiunshinn.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# 시간 복잡도 : o(n) for loop
2-
# 공간 복잡도 o(1) hash map
1+
# 시간 복잡도 : o(n)
2+
# 공간 복잡도 o(n)
33

44

55
class Solution:
@@ -12,3 +12,19 @@ def containsDuplicate(self, nums: List[int]) -> bool:
1212
hashmap[n] = i
1313
return False
1414

15+
16+
# -------------------------------------------------------------------------------------------------------- #
17+
18+
# 시간 복잡도 : o(n)
19+
# 공간 복잡도 o(n)
20+
21+
22+
class Solution:
23+
def containsDuplicate(self, nums: List[int]) -> bool:
24+
seen = set()
25+
26+
for n in nums:
27+
if n in seen:
28+
return True
29+
seen.add(n)
30+
return False

0 commit comments

Comments
 (0)