Skip to content

Commit abdbd1d

Browse files
committed
contains-duplicate
1 parent f1c1fee commit abdbd1d

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

contains-duplicate/Jay-Mo-99.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
class Solution(object):
1+
class Solution(object):
22
def containsDuplicate(self, nums):
33
"""
44
:type nums: List[int]
55
:rtype: bool
66
"""
7-
#??
8-
#sets don't allow duplicate elements.
7+
#해석
8+
#sets는 복수 요소를 허용하지 않는다(sets don't allow duplicate elements.)
9+
#만약 set에 기반된 list가 기존 nums와 길이가 다르다면 duplicate element가 있었다는 뜻이다.
910
#If the length of the set created from nums is different from the original list(nums), It means there are duplicates.
1011

1112
#Big O
12-
#N: ??? ?? nums? ??(Length of the input list nums)
13-
#
13+
#N: 주어진 배열 nums의 길이(Length of the input list nums)
14+
1415
#Time Complexity: O(N)
15-
#- set? nums? ?? n? ???? ????(Creating a set from nums): O(N)
16-
#- ??? list? ?? nums?? ??? ??(Comparing the lengths between created list and original list) : O(1)
17-
#
16+
#- set은 nums의 길이 n에 기반하여 생성된다(Creating a set from nums): O(N)
17+
#- 생성된 list와 기존 nums와의 비교는 상수(Comparing the lengths between created list and original list) : O(1)
18+
1819
#Space Complexity: O(N)
19-
#-set? nums? ??? ?? ????? n? ????(The set requires extra space depends on the size of nums) : O(N)
20+
#-set은 nums의 길이에 의해 생성되므로 n에 영향받음(The set requires extra space depends on the size of nums) : O(N)
2021
if len(list(set(nums))) == len(nums):
2122
return False
2223
else:

0 commit comments

Comments
 (0)