본문 바로가기

코딩테스트

25.07.12 프로그래머스 - 추억점수

문제 및 코드

 

프로그래머스 

 

프로그래머스

SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr

 

function solution(name, yearning, photo) {
    const arr = name.reduce((t, v, i) => {
        t[v] = yearning[i];     
        return t;
    }, {});
    
    const result = photo.map(v => 
        v.reduce((tot, val) => tot += arr[val] ?? 0, 0));
    
    return result;
}