프로그래머스 42748 K번째수

Jmnote (토론 | 기여)님의 2023년 12월 24일 (일) 11:19 판 (새 문서: ==개요== {{프로그래머스|레벨=1|페이지=4|분류=정렬}} ==C++== <syntaxhighlight lang='cpp'> #include <string> #include <vector> #include <algorithm> using namespace std...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

프로그래머스 42748 K번째수

2 C++[ | ]

#include <string>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> solution(vector<int> array, vector<vector<int>> commands) {
    vector<int> answer;
    for(const auto& c: commands) {
        vector<int> v = vector<int>(array.begin()+(c[0]-1), array.begin()+(c[1]));
        sort(v.begin(), v.end());
        answer.push_back(v[c[2]-1]);
    }
    return answer;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}