문제 : 완주하지못한 선수
출처 : 프로그래머스
function solution(participant, completion) {
const newParticipant = participant.sort()
const copletedParticipant = completion.sort()
let result = ''
result = participant.find((p,idx)=>(newParticipant[idx] !== copletedParticipant[idx]))
return result;
}
이번문제는 출발한 참가자중 완주하지 못한 참가자를 찾는 문제입니다.
제가 한 풀이 방식은 참가자중에는 동명 이인이 있을 수 있으므로
1. sort 메서드를 활용해 참가자와 완주자를 정렬
2. find 메서드를 통해 조건과 맞지않는 대상을 찾았습니다.