We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0d7e8da commit ad607f4Copy full SHA for ad607f4
contains-duplicate/delight010.swift
@@ -2,8 +2,11 @@ class Solution {
2
func containsDuplicate(_ nums: [Int]) -> Bool {
3
var dictionary: [Int: Int] = [:]
4
for (index, num) in nums.enumerated() {
5
+ // 배열 nums의 개수만큼 반복합니다. 시간복잡도 O(n)
6
if let value = dictionary[num], value != index {
7
return true
8
+ // 만일 동일한 숫자를 일찍 찾게 된다면
9
+ // 시간복잡도는 O(n)보다 더 빨라질 수 있습니다.
10
}
11
dictionary[num] = index
12
0 commit comments