문제

https://programmers.co.kr/learn/courses/30/lessons/42748

코드

#include <string>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> solution(vector<int> array, vector<vector<int>> commands) {
    vector<int> answer;
    vector<int> newArray;

    for(int i = 0; i < commands.size(); i++) {

            int start = commands[i][0]-1;
            int end = commands[i][1]-1;
            int k = commands[i][2]-1;
            for(int j = start; j <= end; j++) {
                newArray.push_back(array[j]);
            }

        std::sort(newArray.begin(),newArray.end());
        answer.push_back(newArray[k]);
        newArray.clear();
    }

    return answer;
}