Skip to content

Commit f8bca4e

Browse files
committed
Crane_Doll_Picking_Game / 중급
1 parent a359bb2 commit f8bca4e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function solution(board, moves) {
2+
let N = board.length;
3+
let stack = [];
4+
let count = 0;
5+
for (let i = 0; i < moves.length; i++) {
6+
for (let j = 0; j < N; j++) {
7+
if (board[j][moves[i] - 1] !== 0) {
8+
stack.push(board[j][moves[i] - 1]);
9+
if (stack[stack.length - 1] == stack[stack.length - 2]) {
10+
count++;
11+
count++;
12+
stack.pop();
13+
stack.pop();
14+
}
15+
board[j][moves[i] - 1] = 0;
16+
break;
17+
}
18+
}
19+
}
20+
return count;
21+
}

0 commit comments

Comments
 (0)