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 c90945b commit 94221e5Copy full SHA for 94221e5
bona1122/[week3]Queue/Burger_making.js
@@ -0,0 +1,18 @@
1
+// https://school.programmers.co.kr/learn/courses/30/lessons/133502
2
+
3
+function solution(ingredient) {
4
+ let stack = [];
5
+ let result = 0;
6
+ for (let i = 0; i < ingredient.length; i++) {
7
+ let item = ingredient[i];
8
+ stack.push(item);
9
+ if (stack.length >= 4) {
10
+ let last4 = stack.slice(-4);
11
+ if (last4.join("") === "1231") {
12
+ result++;
13
+ stack.splice(-4);
14
+ }
15
16
17
+ return result;
18
+}
0 commit comments