[Lv.1] 추억 점수
Last updated
Last updated
import java.util.*;
class Solution {
public int[] solution(String[] name, int[] yearning, String[][] photo) {
Map<String, Integer> nameMap = new HashMap<>();
int [] result;
result = new int[photo.length];
for (int i = 0; i <= name.length-1; i++){
nameMap.put(name[i], yearning[i]);
}
for(int i = 0; i <= photo.length-1; i++){
int score =0;
for(int j = 0; j <=photo[i].length-1; j++){
if(nameMap.containsKey(photo[i][j])){
score += nameMap.get(photo[i][j]);
}
}
result[i] = score;
}
return result;
}
}