*k번째 수(정렬) #include <iostream> #include <algorithm> #include <vector> using namespace std; vector solution(vector array, vector<vector> commands) { vector answer; for(auto elem : commands) { vector temp; for(int i = elem[0] - 1; i < elem[1]; i++) { temp.push_back(array[i]); } sort(temp.begin(), temp.end(), less<int>()); answer.push_back(temp[elem[2] - 1]); } return answer; } | cs |
::public/코딩테스트 풀이