Make Unreal REAL.
article thumbnail
Level 0. 코드 처리하기

 

 

#include <iostream>

using namespace std;

string solution(string code)
{
    bool mode = false;
    size_t len = code.length();
    string answer;

    for (int i = 0; i < len; ++i)
        if (code[i] == '1')
            mode = !mode;
        else if ( (i & 1) == (mode ? 1 : 0) )
            answer += code[i];

    return answer.empty() ? "EMPTY" : answer;
}

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

Level 2. [1차] 뉴스 클러스터링  (0) 2023.05.11
Level 0. 커피 심부름  (0) 2023.05.10
Level 2. [1차] 프렌즈4블록  (0) 2023.05.08
Level 2. 삼각 달팽이  (0) 2023.05.07
Level 0. 배열 조각하기  (0) 2023.05.06
profile

Make Unreal REAL.

@diesuki4

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

검색 태그