import Foundation

func solution(_ lottos:[Int], _ win_nums:[Int]) -> [Int] {
    let rank = [6,5,4,3,2]
    let lottoSet: Set<Int> = Set(lottos)
    let win_numSet: Set<Int> = Set(win_nums)
    let inter = lottoSet.intersection(win_numSet)
    var first = inter.count + lottos.filter { $0 == 0 }.count
    first = (first >= 2) ? rank.firstIndex(of: first)!+1 : 6
    var last = inter.count
    last = (last >= 2) ? (rank.firstIndex(of: last) ?? 0) + 1 : 6
    return [first, last]
}
ytw_developer