티스토리 뷰

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
댓글
공지사항