문제 링크 (opens new window)

# 풀이

import Foundation

func solution(_ name:[String], _ yearning:[Int], _ photo:[[String]]) -> [Int] {
    var point: [String: Int] = [:]
    var result: [Int] = []

    for (index, value) in yearning.enumerated() {
        point[name[index]] = value
    }

    for (index, p) in photo.enumerated() {
        result.append(0)
        for n in p {
            if let _ = point[n] {
                result[index] += point[n]!
            }
        }
    }

    return result
}