File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change 1
- class Solution (object ):
1
+ class Solution (object ):
2
2
def containsDuplicate (self , nums ):
3
3
"""
4
4
:type nums: List[int]
5
5
:rtype: bool
6
6
"""
7
- #??
8
- #sets don't allow duplicate elements.
7
+ #해석
8
+ #sets는 복수 요소를 허용하지 않는다(sets don't allow duplicate elements.)
9
+ #만약 set에 기반된 list가 기존 nums와 길이가 다르다면 duplicate element가 있었다는 뜻이다.
9
10
#If the length of the set created from nums is different from the original list(nums), It means there are duplicates.
10
11
11
12
#Big O
12
- #N: ??? ?? nums? ?? (Length of the input list nums)
13
- #
13
+ #N: 주어진 배열 nums의 길이 (Length of the input list nums)
14
+
14
15
#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
+
18
19
#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)
20
21
if len (list (set (nums ))) == len (nums ):
21
22
return False
22
23
else :
You can’t perform that action at this time.
0 commit comments