# 완주하지 못한 선수
Javascript
function solution(participant, completion) {
var dic = {};
participant.forEach(ele => {
if (ele in dic) {
dic[ele] += 1;
} else {
dic[ele] = 1;
}
});
completion.forEach(ele => {
if (ele in dic) {
dic[ele] -= 1;
}
});
for (var k in dic) {
if (dic[k] == 1) {
return k;
}
}
}
Python
def solution(participant, completion):
d = dict()
for ele in participant:
if ele in d:
d[ele] += 1
else:
d[ele] = 1
for each in completion:
d[each] -= 1
answer = ""
for i in d:
if d[i] == 1:
answer = i
return answer