1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-19 17:56:55 +02:00
LeetCode/swift/contains-duplicate.swift

13 lines
286 B
Swift
Raw Normal View History

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
}
}