Skip to content

Latest commit

 

History

History
13 lines (11 loc) · 278 Bytes

FindRepeatsSolution.md

File metadata and controls

13 lines (11 loc) · 278 Bytes

Find Repeats Solution

Swift

func findRepeats(in arr: [Int]) -> [Int] {
    var frequencyDict = [Int: Int]()
    for num in arr {
        frequencyDict[num] = frequencyDict[num, default: 0] + 1
    }
    return Array(frequencyDict.filter{$0.value > 1}.keys)
}