Skip to content

Commit 31ea7ad

Browse files
author
sejineer
committed
contains-duplicate solution
1 parent f291ae8 commit 31ea7ad

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

contains-duplicate/sejineer.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""
2+
시간 복잡도 O(n)
3+
공간 복잡도 O(n)
4+
5+
코드 가독성 향상 코드
6+
class Solution:
7+
def containsDuplicate(self, nums: List[int]) -> bool:
8+
return len(nums) != len(set(nums))
9+
"""
10+
class Solution:
11+
def containsDuplicate(self, nums: List[int]) -> bool:
12+
check = set([])
13+
for i in nums:
14+
if i not in check:
15+
check.add(i)
16+
else:
17+
return True
18+
return False

0 commit comments

Comments
 (0)