웅재의 코딩세상
[프로그래머스] k번째수 본문
- 풀이
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> array, vector<vector<int>> commands) {
vector<int> answer;
for(int i=0; i< commands.size(); i++){
vector<int> v;
for(int j=commands[i][0]-1; j < commands[i][1]; j++ ){
v.push_back(array[j]);
}
sort(v.begin(), v.end());
answer.push_back(v[commands[i][2]-1]);
}
return answer;
}
반응형
'코딩테스트 > 프로그래머스 - LV 1' 카테고리의 다른 글
[프로그래머스] 삼총사 (0) | 2024.02.14 |
---|---|
[프로그래머스] 문자열 내 마음대로 정렬하기 (0) | 2024.02.13 |
[프로그래머스] 가운데 글자 가져오기 (0) | 2024.02.09 |
[프로그래머스] 같은 숫자는 싫어 (0) | 2024.02.09 |
[프로그래머스] 나누어 떨어지는 숫자 배열 (0) | 2024.02.09 |