LeetCode/study-plan/data-structure/day-01/contains-duplicate.swift
Matej Focko 5d622d4583
data-structure(i): add day 2 and rename day 1
Signed-off-by: Matej Focko <mfocko@redhat.com>
2022-01-20 15:42:43 +01:00

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