Skip to content

Commit ad607f4

Browse files
committed
Add comments to contains-duplicate
1 parent 0d7e8da commit ad607f4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

contains-duplicate/delight010.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ class Solution {
22
func containsDuplicate(_ nums: [Int]) -> Bool {
33
var dictionary: [Int: Int] = [:]
44
for (index, num) in nums.enumerated() {
5+
// 배열 nums의 개수만큼 반복합니다. 시간복잡도 O(n)
56
if let value = dictionary[num], value != index {
67
return true
8+
// 만일 동일한 숫자를 일찍 찾게 된다면
9+
// 시간복잡도는 O(n)보다 더 빨라질 수 있습니다.
710
}
811
dictionary[num] = index
912
}

0 commit comments

Comments
 (0)