웅재의 코딩세상

[프로그래머스] 추억 점수 본문

코딩테스트/프로그래머스 - LV 1

[프로그래머스] 추억 점수

웅드 2024. 2. 14. 18:56

 

  • 풀이
#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> mp;
    for(int i=0; i<name.size(); i++) mp[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 += mp[photo[i][j]];
        }
        answer.push_back(sum);
    }
    return answer;
}
반응형