Skip to content

Commit 0d38c78

Browse files
committed
contains-duplicate solution
1 parent 08a8b9a commit 0d38c78

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

contains-duplicate/6kitty.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# @lc app=leetcode id=217 lang=python3
3+
#
4+
# [217] Contains Duplicate
5+
#
6+
7+
# @lc code=start
8+
class Solution:
9+
def containsDuplicate(self, nums: List[int]) -> bool:
10+
# list로 하니까 시간 초과 떠서 set으로 변경
11+
idx=set()
12+
for i in nums:
13+
if i in idx:
14+
return True
15+
idx.add(i)
16+
# null 방지
17+
return False
18+
19+
# @lc code=end
20+

0 commit comments

Comments
 (0)