웅재의 코딩세상

[프로그래머스] 배열 만들기 3 본문

코딩테스트/프로그래머스 - LV 0

[프로그래머스] 배열 만들기 3

웅드 2024. 1. 31. 16:30

 

 

  • 풀이
#include <string>
#include <vector>

using namespace std;

vector<int> solution(vector<int> arr, vector<vector<int>> intervals) {
    vector<int> answer;
    for(int i=0; i<intervals.size(); i++){
        for(int j=intervals[i][0]; j<intervals[i][1]+1; j++){
            answer.push_back(arr[j]);
        }
    }
    return answer;
}
반응형