728x90
반응형

#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> temp;
for(int j = commands[i][0]-1 ; j < commands[i][1]; j ++)
{
temp.push_back(array[j]);
}
sort(temp.begin(), temp.end());
answer.push_back(temp[commands[i][2]-1]);
}
return answer;
}
728x90
반응형
'Computer Science > Coding Test' 카테고리의 다른 글
SQL 프로그래머스 : 코딩테스트 - 동명 동물 수 찾기 (0) | 2023.01.30 |
---|---|
c++(cpp) 프로그래머스 : 코딩테스트 - 완주하지 못한 선수 (0) | 2023.01.23 |
c++(cpp) 프로그래머스 - 코딩 테스트 : 두 정수 사이의 합 (0) | 2022.08.13 |
c++(cpp) 프로그래머스 - 코딩 테스트 : 3진법 뒤집기 (0) | 2022.08.11 |
c++(cpp) 프로그래머스 - 코딩 테스트 : 문자열 내 p와 y의 개수 (0) | 2022.08.11 |
댓글