-
프로그래머스 / 추억 점수코딩 테스트/Level 1 2023. 4. 1. 07:47반응형
https://school.programmers.co.kr/learn/courses/30/lessons/176963
파이썬
def solution(name, yearning, photo): scores = {n: s for n, s in zip(name, yearning)} return [sum(scores.get(person, 0) for person in pic) for pic in photo]
def solution(name, yearning, photo): return [sum({n: s for n, s in zip(name, yearning)}.get(person, 0) for person in pic) for pic in photo]
코틀린
class Solution { fun solution(name: Array<String>, yearning: IntArray, photo: Array<Array<String>>): IntArray { return photo.map { it.sumOf { each -> name.toList() .zip(yearning.toList()) .toMap() .getOrDefault(each, 0) } }.toIntArray() } }
반응형