import java.util.*;
class Solution {
public String solution(String[] participant, String[] completion) {
String answer = "";
Map<String, Integer> map = new HashMap<>();
for(String item : participant) {
map.computeIfPresent(item,(String key, Integer value)->++value);
map.putIfAbsent(item,1);
}
for(String comple : completion) {
map.computeIfPresent(comple,(String key, Integer value)->--value);
}
for(int i=0;i<participant.length;i++) {
if(map.get(participant[i])!=0) {
answer=participant[i];
}
}
return answer;
}
}
'문제풀이' 카테고리의 다른 글
[백준] 호석이 두마리치킨 JAVA (0) | 2021.04.08 |
---|---|
프로그래머스 베스트앨범 Java + Collection Sort와 Comparator 정리 (0) | 2021.04.03 |
프로그래머스 체육복 Java (0) | 2021.03.31 |
프로그래머스 H-Index Java (0) | 2021.03.31 |
프로그래머스 가장 큰 수 JAVA (0) | 2021.03.27 |