Skip to content

Commit 9bd1415

Browse files
committed
Delivery Box / 심화
1 parent e00f4cd commit 9bd1415

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function solution(order) {
2+
let stack = [];
3+
let current = 1;
4+
let count = 0;
5+
6+
for (let box of order) {
7+
while (current <= box) {
8+
stack.push(current++);
9+
}
10+
if (stack.pop() === box) {
11+
count++;
12+
} else {
13+
break;
14+
}
15+
}
16+
17+
return count;
18+
}

0 commit comments

Comments
 (0)