We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0f86bdd commit da947b9Copy full SHA for da947b9
sorting/programmers/42748/solution.cpp
@@ -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