47분 소요

1명 제외, 모든 선수가 마라톤 완주 : 100,000명 이하
완주하지 못한 선수의 이름을 return , 참가자 중 동명이인이 있을 수 있다.
10분 소요.
import java.util.*;
class Solution {
public String solution(String[] participant, String[] completion) {
String answer = "";
HashMap<String,Integer> completionTable = new HashMap<>();
for( String x: completion) {
if(!completionTable.containsKey(x)) completionTable.put(x,1);
else {
completionTable.replace(x,completionTable.get(x)+1);
}
}
for(String x : participant) {
if(!completionTable.containsKey(x) || completionTable.get(x) == 0) {
answer = x;
break;
}
else {
completionTable.replace(x,completionTable.get(x)-1);
}
}
return answer;
}
}
O(N)