✨ 정답 ✨
function solution(n, lost, reserve) {
let realReserve=reserve.filter((el)=>!lost.includes(el));
let realLost = lost.filter((el)=>!reserve.includes(el));
realReserve.sort();
realLost.sort();
let answer = n-realLost.length;
let count=0;
for (let i=0;i<realReserve.length;i++){
if (realLost.includes(realReserve[i]-1)){
realLost=realLost.filter((el)=>{
return el!==realReserve[i]-1;
});
answer+=1;
console.log('answer', answer, realLost)
}else if (realLost.includes(realReserve[i]+1)){
realLost=realLost.filter((el)=>{
return el!==realReserve[i]+1;
})
answer+=1;
}
}
return answer;
}
🧵 참고한 정답지 🧵
💡💡 기억해야 할 점 💡💡