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;
for(auto i:commands){
vector<int> temp;
for(int j=i[0]-1;j<=i[1]-1;j++)
temp.push_back(array[j]);
sort(temp.begin(),temp.end());
answer.push_back(temp[i[2]-1]);
}
return answer;
}
큰 어려움 없이 문제에서 하라는대로 하면됩니다. 코드 보시면 temp에다가 문제에서 주는 범위만큼 array값을 입력하고 sort를 사용해서 정렬했습니다