function solution(arr) { let answer=[]; let prevNum=-1; for(let i=0;i<arr.length;i++){ if(arr[i]===prevNum){ prevNum=arr[i]; arr[i]=-1 continue } prevNum=arr[i]; } answer=arr.filter(a=>a!==-1); return answer; }
어렵다 생각하면 어려운 문제