Skip to content

Commit 5dadc6e

Browse files
committed
solve
1 parent 0fc7ec8 commit 5dadc6e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

contains-duplicate/sonjh1217.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
// time O(n) / space O(n)
3+
func containsDuplicate(_ nums: [Int]) -> Bool {
4+
var numSet = Set<Int>()
5+
for num in nums {
6+
if numSet.contains(num) {
7+
return true
8+
}
9+
numSet.insert(num)
10+
}
11+
12+
return false
13+
}
14+
}

0 commit comments

Comments
 (0)