• Home
  • About
    • Dochoi의 소소한 코딩 모음 photo

      Dochoi의 소소한 코딩 모음

      코딩을 하면서 느낀점들을 모은 공간입니다.

    • Learn More
    • Email
    • Github
  • Posts
    • All Posts
    • All Tags
    • AI
    • Algorithm
    • Algorithm-Test
    • Cloud
    • Docker
    • Kubernetes
    • iOS
    • Culture
  • Projects

[프로그래머스] : 종이접기

16 Jun 2020

Reading time ~1 minute

algorithm-test
#include <string>
#include <vector>
#include <iostream>
using namespace std;

vector<int> solution(int n) {
    vector<int> answer;
    answer.push_back(0);
    for(int i = 1; i < n ; i++)
    {
        int size_ = answer.size() - 1;
        answer.push_back(0);
    
        for(int j = size_; j >=0 ; j--)
            answer.push_back(!(answer[j]));
    }

    return answer;
}

구현방법

규칙을 찾아야한다.

0

001

0010011

001001100011011

자신이 그대로 나온 후, 0이 붙고 거꾸로 탐색하면서 반전시킨 값이 들어간다.



Algorithm-TestProgrammersKakao Share Tweet +1