https://school.programmers.co.kr/learn/courses/30/lessons/42748
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
코드
// 배열 arr의 i부터 j까지 자르고 정렬했을 때 k번째에 있는 수 구하기
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> array, vector<vector<int>> commands) {
vector<int> answer;
for (auto& i : commands) {
vector<int> v;
for (int j = i[0] - 1; j < i[1]; j++) {
v.push_back(array[j]);
}
sort(v.begin(), v.end());
answer.push_back(v[i[2] - 1]);
}
return answer;
}
'알고리즘 > Programmers' 카테고리의 다른 글
[프로그래머스/C++] 가장 큰 수 (0) | 2022.05.19 |
---|---|
[프로그래머스/C++] 더 맵게 (0) | 2022.05.19 |
[프로그래머스/C++] 기능 개발 (0) | 2022.05.19 |
[프로그래머스/C++] 전화번호 목록 (0) | 2022.05.18 |
[프로그래머스/C++] 완주하지 못 한 선수 (0) | 2022.04.30 |