1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| const solution = (p, c) => {
p.sort();
c.sort();
let answer = '';
let index = 0;
while(index < p.length) {
if (p[index] !== c[index]) {
answer = p[index];
break;
}
index++;
}
return answer;
};
|
1
| var solution=(_,$)=>_.find(_=>!$[_]--,$.map(_=>$[_]=($[_]|0)+1))
|
1
| var solution=(participant,completion)=>participant.find(name=>!completion[name]--,completion.map(name=>completion[name]=(completion[name]|0)+1))
|
completion을 map을 이용하여 항목에 있는 것들의 갯수를 세서 completion에 key-value로 추가한다.
이때 추가된 completion을 find에서 사용하여 participant의 name을 key로 개수를 세서 개수가 0인것을 찾는다.