mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-14 01:49:41 +01:00
13 lines
286 B
Swift
13 lines
286 B
Swift
|
class Solution {
|
||
|
func containsDuplicate(_ nums: [Int]) -> Bool {
|
||
|
var encountered = Set<Int>()
|
||
|
for x in nums {
|
||
|
if encountered.contains(x) {
|
||
|
return true
|
||
|
}
|
||
|
encountered.insert(x)
|
||
|
}
|
||
|
return false
|
||
|
}
|
||
|
}
|