Make Unreal REAL.
article thumbnail
Level 0. 배열의 길이를 2의 거듭제곱으로 만들기

 

 

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> solution(vector<int> arr)
{
    size_t o_size = arr.size();
    size_t new_size = 0b1;

    while (new_size < o_size)
        new_size <<= 1;

    arr.resize(new_size);
    fill(arr.begin() + o_size, arr.end(), 0);

    return arr;
}

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

Level 0. 조건에 맞게 수열 변환하기 2  (0) 2023.04.28
Level 0. 정사각형으로 만들기  (0) 2023.04.28
Level 0. 문자열 묶기  (0) 2023.04.27
Level 0. 2의 영역  (0) 2023.04.26
Level 0. qr code  (0) 2023.04.25
profile

Make Unreal REAL.

@diesuki4

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

검색 태그