We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a359bb2 commit f8bca4eCopy full SHA for f8bca4e
Moonjonghoo/stack/Crane_Doll_Picking_Game.js
@@ -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
12
+ stack.pop();
13
14
+ }
15
+ board[j][moves[i] - 1] = 0;
16
+ break;
17
18
19
20
+ return count;
21
+}
0 commit comments