Make Unreal REAL.
article thumbnail
Level 0. 배열 만들기 4

 

 

#include <iostream>
#include <vector>

using namespace std;

vector<int> solution(vector<int> arr)
{
    vector<int> stk;

    for (int i = 0; i < arr.size(); ++i)
        if (stk.empty() || stk.back() < arr[i])
            stk.emplace_back(arr[i]);
        else
            stk.pop_back(),
            --i;

    return stk;
}

'자료구조 & 알고리즘 > 프로그래머스' 카테고리의 다른 글

Level 0. 수열과 구간 쿼리 2  (0) 2023.05.15
Level 0. 두 수의 합  (1) 2023.05.14
Level 0. 배열 만들기 2  (0) 2023.05.12
Level 2. [1차] 뉴스 클러스터링  (0) 2023.05.11
Level 0. 커피 심부름  (0) 2023.05.10
profile

Make Unreal REAL.

@diesuki4

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!

검색 태그