반응형
문제
https://programmers.co.kr/learn/courses/30/lessons/42748
#include <string> #include <vector> #include <algorithm> using namespace std; vector<int> solution(vector<int> array, vector<vector<int>> commands) { vector<int> answer; int s, e, t, ret; //시작, 끝, 타겟, 결과값 for(int i=0; i<commands.size(); i++) { vector<int> tmp; // index값이므로 -1씩 해줌 s=commands[i][0]-1; e=commands[i][1]-1; t=commands[i][2]-1; for(int j=s; j<=e; j++) { tmp.push_back(array[j]); } sort(tmp.begin(), tmp.end()); ret=tmp[t]; answer.push_back(ret); } return answer; } |
반응형
'Algorithm' 카테고리의 다른 글
[BOJ 5543] 상근날드 (0) | 2018.12.18 |
---|---|
[카카오 2019 신입공채 1차 코딩테스트] 6.매칭 점수 (0) | 2018.11.14 |
[BOJ 2293] 동전 1 (0) | 2018.11.12 |
[BOJ 2309] 일곱 난쟁이 (0) | 2018.11.12 |
[BOJ 3053] 택시 기하학 (0) | 2018.11.12 |