func solution(_ id_list:[String], _ report:[String], _ k:Int) -> [Int] {
let report = Set(report).map { String($0) }
var dict = [String: [String]]()
var result = [Int]()
for string in report {
let stringArray = string.split(separator: " ").map { String($0) }
let reporter = stringArray.first!
let reported = stringArray.last!
if dict[reported] == nil {
dict.updateValue([reporter], forKey: reported)
} else {
var reporters = dict[reported]!
reporters.append(reporter)
dict.updateValue(reporters, forKey: reported)
}
}
let resultDict = Dictionary(dict.filter { $0.value.count >= k }.values.flatMap { $0 }.map { ($0, 1) }, uniquingKeysWith: +)
for i in id_list {
if let num = resultDict[i] {
result.append(num)
} else {
result.append(0)
}
}
return result
}