프로그래머스 133502 햄버거 만들기

Jmnote (토론 | 기여)님의 2023년 11월 29일 (수) 01:00 판 (새 문서: ==개요== {{프로그래머스|레벨=1|페이지=2|분류=연습문제}} ==C++== <syntaxhighlight lang='cpp'> #include <string> #include <vector> using namespace std; int solutio...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

프로그래머스 133502 햄버거 만들기

2 C++[ | ]

#include <string>
#include <vector>

using namespace std;

int solution(vector<int> ingredient) {
    int answer = 0;
    vector<int> v;
    for(int el: ingredient) {
        v.push_back(el);
        int size = v.size();
        if(size >=4 && v[size-4]==1 && v[size-3]==2 && v[size-2]==3 && v[size-1]==1) {
            answer++;
            int t=4;
            while(t--) v.pop_back();
        }
    }
    return answer;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}