From 0ee6aa0e2019d258dceb8f1dc4292fc4d6c9a5b6 Mon Sep 17 00:00:00 2001 From: SSOOYA Date: Thu, 14 Mar 2024 08:17:30 +0900 Subject: [PATCH] =?UTF-8?q?solve/#189:=20swift=20=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...54\226\265 \354\240\220\354\210\230.swift" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "AlgorithmReview/Programmers/LV1/\354\266\224\354\226\265 \354\240\220\354\210\230.swift" diff --git "a/AlgorithmReview/Programmers/LV1/\354\266\224\354\226\265 \354\240\220\354\210\230.swift" "b/AlgorithmReview/Programmers/LV1/\354\266\224\354\226\265 \354\240\220\354\210\230.swift" new file mode 100644 index 0000000..5711f4c --- /dev/null +++ "b/AlgorithmReview/Programmers/LV1/\354\266\224\354\226\265 \354\240\220\354\210\230.swift" @@ -0,0 +1,23 @@ +// +// 추억 점수.swift +// AlgorithmReview +// +// Created by 박소윤 on 2024/03/14. +// + +import Foundation + +func solution(_ name:[String], _ yearning:[Int], _ photo:[[String]]) -> [Int] { + + var map = [String: Int]() + for (n,y) in zip(name, yearning) { + map[n] = y + } + + var answer = [Int]() + for p in photo { + answer.append(p.reduce(0){ $0 + (map[$1] ?? 0) }) + } + + return answer +}