코딩테스트
코딩테스트 연습 > 2019 카카오 개발자 겨울 인턴십 > 크레인 인형뽑기 게임
안양사람
2020. 6. 25. 15:57
728x90
SMALL
풀이
function solution(board, moves) {
let arr=[];
for(let i=0;i<moves.length;i++){
for(let j=0;j<board.length;j++){
if(board[j][moves[i]-1]!==0){
arr.push(board[j][moves[i]-1]);
board[j].splice(moves[i]-1,1,0);
break;
}
}
}
let answer=0;
for(let i=0;i<arr.length;i++){
if(arr[i]===arr[i+1]){
arr.splice(i,2);
answer+=2;
i=-1;
}
}
return answer;
}
728x90
LIST