Skip to content

Commit cad1385

Browse files
committed
contains duplicate solution
1 parent 0fc7ec8 commit cad1385

File tree

1 file changed

+15
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)