반응형
단순구현 문제
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <string>
#include <vector>
#include<algorithm>
using namespace std;
vector<int> solution(vector<int> array, vector<vector<int>> commands) {
vector<int> answer;
for(int ii=0; ii<commands.size(); ii++){
int i=commands[ii][0], j=commands[ii][1], k=commands[ii][2];
vector<int> list;
for(int a=i-1; a<=j-1; a++){
list.push_back(array[a]);
}
sort(list.begin(), list.end());
answer.push_back(list[k-1]);
}
return answer;
}
|
cs |
반응형
'알고리즘 문제풀이' 카테고리의 다른 글
[Programmers] 프로그래머스 Lv.2 H-Index 문제풀이(C++) (0) | 2024.05.24 |
---|---|
[Programmers] 프로그래머스 Lv.1 덧칠하기 문제풀이(Python) (1) | 2024.05.07 |
[Programmers] 프로그래머스 Lv.2 게임 맵 최단거리 문제풀이(C++) (0) | 2024.04.16 |
[Programmers] 프로그래머스 Lv.2 조건에 맞는 도서와 저자 리스트 출력하기 문제풀이(MySQL) (0) | 2024.02.24 |
[Programmers] 프로그래머스 Lv.3 조건별로 분류하여 주문상태 출력하기 문제풀이(MySQL) (0) | 2024.02.24 |