[프로그래머스 C++]/LEVEL 1
[프로그래머스 C++] K번째수
AKI(JUNI)
2025. 3. 31. 17:14
◈ 문제 설명
◈ 문제 설명 링크
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
◈ 작성 코드
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> array, vector<vector<int>> commands)
{
vector<int> answer;
vector<int> t;
for(int i = 0; i < commands.size(); i++)
{
for(int j = commands[i][0] - 1; j < commands[i][1]; j++)
{
t.push_back(array[j]);
}
sort(t.begin(), t.end());
answer.push_back(t[commands[i][2] - 1]);
t = {};
}
return answer;
}