#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> array, vector<vector<int>> commands) {
vector<int> answer;
for(int i = 0; i < commands.size(); i++)
{
int begin = commands[i][0];
int end = commands[i][1];
int target = commands[i][2];
int size = end - begin + 1;
vector<int>v(size);
int index = 0;
for(int j = begin -1; j <= end -1; j++)
v[index++] = array[j];
sort(v.begin(), v.end());
answer.push_back(v[target -1]);
}
return answer;
}
vectorv(v1.begin(), v1.end()) 이렇게 복사를 해왔다.
그래서 index값을 넣을수 있지 않을까 생각했는데 안된다.
벡터 초기화
: 이런식으로 가능하다.
하지만 + 1을 더 진행해야 한다.
sort(v.begin(), v.end()) 이런식으로 했다.
이터레이터인 v.begin()을 이용하자!