import java.util.Arrays;
class Solution {
public int solution(int[] ingredient) {
int[] stack = new int[ingredient.length];
int idx = 0;
int hamburger = 0;
for ( int i : ingredient ) {
stack[idx++] = i;
if (
idx >= 4 &&
stack[idx-4] == 1 &&
stack[idx-3] == 2 &&
stack[idx-2] == 3 &&
stack[idx-1] == 1
)
{
hamburger++;
idx-=4;
}
}
return hamburger;
}
}
https://school.programmers.co.kr/learn/courses/30/lessons/133502