Algorithm/programmers
[NodeJS] 프로그래머스 완주하지 못한 선수
castlemo
2022. 8. 19. 16:51
728x90
/**
* @link https://school.programmers.co.kr/learn/courses/30/lessons/42576?language=javascript
* @description
*/
const solution = (participant, completion) => {
const map = {};
for (const p of participant) {
map[p] = map[p] ? map[p] + 1 : 1;
}
for (const c of completion) {
map[c]--;
}
for (const k in map) {
if (map[k] > 0) {
return k;
}
}
};
728x90