프로그래머스 <추억 점수>

마스터피스·2024년 2월 1일

코딩테스트 문제

목록 보기
11/21
post-thumbnail
#include <string>
#include <vector>
#include <map>

using namespace std;

vector<int> solution(vector<string> name, vector<int> yearning, vector<vector<string>> photo) {
    vector<int> answer;
    map<string, int> m;
    for(int i = 0; i < name.size(); i++){
        m[name[i]] = yearning[i];
    }
    for(int i = 0; i < photo.size(); i++){
        int sum = 0;
        for(int j = 0; j < photo[i].size(); j++){
            sum += m[photo[i][j]];
        }
        answer.push_back(sum);
    }
    return answer;
}
profile
코딩 일지

0개의 댓글