1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-20 01:56:57 +02:00
LeetCode/problems/contains-duplicate.swift
Matej Focko 96c6e8d66d
problems: add previously solved problems
Signed-off-by: Matej Focko <mfocko@redhat.com>
2022-01-18 21:43:49 +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
}
}