Created
September 17, 2019 23:04
-
-
Save surinoel/9980282095d317c079ec7decb22e1c70 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
vector<int> solution(vector<int> array, vector<vector<int>> commands) { | |
vector<int> answer; | |
int size = commands.size(); | |
for (int test_case = 0; test_case < size; test_case++) { | |
int i, j, k; | |
i = commands[test_case][0]; | |
j = commands[test_case][1]; | |
k = commands[test_case][2]; | |
vector<int> subarray(array.begin() + i - 1, array.begin() + j); | |
sort(subarray.begin(), subarray.end()); | |
answer.push_back(subarray[k - 1]); | |
} | |
return answer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment