Skip to content

Commit 33aca2b

Browse files
committed
contains duplicate
1 parent c317868 commit 33aca2b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
func containsDuplicate(_ nums: [Int]) -> Bool {
3+
var dictionary: [Int: Int] = [:]
4+
for (index, num) in nums.enumerated() {
5+
if let value = dictionary[num], value != index {
6+
return true
7+
}
8+
dictionary[num] = index
9+
}
10+
return false
11+
}
12+
}
13+

0 commit comments

Comments
 (0)