import java.util.*;
class Solution {
public int[] solution(String[] name, int[] yearning, String[][] photo) {
int[] answer = new int[photo.length];
HashMap<String, Integer> sH = new HashMap<>();
for (int i = 0; i < name.length; i++) {
sH.put(name[i], yearning[i]);
}
for (int i = 0; i < photo.length; i++) {
int score = 0;
for (String x : photo[i]) {
score += sH.getOrDefault(x, 0);
}
answer[i] = score;
}
return answer;
}
}
https://school.programmers.co.kr/learn/courses/30/lessons/176963