Skip to content

Commit da947b9

Browse files
committed
Solution code for programmers/42748
1 parent 0f86bdd commit da947b9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// https://programmers.co.kr/learn/courses/30/lessons/42748
2+
3+
#include <vector>
4+
#include <algorithm>
5+
6+
using namespace std;
7+
8+
vector<int> solution(vector<int> array, vector<vector<int>> commands) {
9+
vector<int> answer;
10+
int length_of_commands = commands.size();
11+
12+
for (int command_index = 0 ; command_index < length_of_commands ; command_index++) {
13+
vector<int> current_command = commands[command_index];
14+
vector<int> sliced_array = vector<int>(array.begin() + current_command[0] - 1, array.begin() + current_command[1]);
15+
sort(sliced_array.begin(), sliced_array.end());
16+
answer.push_back(sliced_array[current_command[2] - 1]);
17+
}
18+
19+
return answer;
20+
}

0 commit comments

Comments
 (0)