LeetCode/study-plan/data-structure/day-1/contains-duplicate.swift
Matej Focko 9fa39e8873
data-structure(i): add day 1
Signed-off-by: Matej Focko <mfocko@redhat.com>
2022-01-19 18:25:31 +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
}
}