Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 최소 #공배수 #최대 #공약수 #유클리드 #호제법 #lcm #gcd #c++ #boj #3343 #백준 #장미
- c++ #boj #
- N번째큰수
- 쌤쌤쌤
- 22869
- 20117
- 3D #Reconstruction #computer #vision #volume #metric #tsdf #kinect #fusion
- 16202
- 사이클 없는 그래프
- C++
- 3343
- graph
- 레드아보
- LIS #가장긴증가하는부분수열 #
- 줄어드는수
- boj #백준
- 진법변환 #2to10 #10to2 #이진법 #십진법 #변환 #bitset #c++
- 코딩
- 이분탐색 #dp #11053
- 투포인터 #백준 #boj #20922 #22862
- 백준
- graph #최단경로
- 호반우 상인
- 30870
- c++ #입출력 #속도 #ios #sync_with_stdio #cin #cout #tie
- BOJ
- 백준 #다익스트라 #dijkstra #9370 #c++
- hcpc
- 1174
- backtracking #codetree #디버깅 #삼성코테
Archives
- Today
- Total
hyunjin
[level 1] k 번째 수 , 2차 풀이 본문
728x90
https://programmers.co.kr/learn/courses/30/lessons/42748
첫 번째 풀이
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<int> array, vector<vector<int>> commands) {
vector<int> answer;
vector<int> temp;
for(int t = 0;t< commands.size() ;t++){
int i=commands[t][0]-1,j= commands[t][1]-1,k=commands[t][2]-1;
for(int z = i ; z <= j ; z++)
temp.push_back(array[z]);
//정렬
for(int x = 1 ; x < j - i + 1 ;x++){
int key = temp[x];
int y = x-1;
while(y>-1 && temp[y]>key){
temp[y+1]=temp[y];
y--;
}
temp[y+1]= key;
}
answer.push_back(temp[k]);
temp.clear();
}
return answer;
}
두 번째 풀이
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<int> array, vector<vector<int>> commands) {
vector<int> answer;
for(auto elem : commands){
vector <int>
}
return answer;
}
728x90
'알고리즘 연습 > 프로그래머스' 카테고리의 다른 글
[level 1] 문자열 내 맘대로 정렬하기 , string compare, pair, sort (0) | 2020.07.14 |
---|---|
[level 1] 같은 숫자는 싫어, iterator 선언 , unique 사용 (0) | 2020.07.13 |
[level 2] 프린터 , queue, max_element=> 활용해 다시 풀어보기 (0) | 2020.07.11 |
[level 1]완주하지 못한 선수 2차 풀이, hash, unordered_map (0) | 2020.07.10 |
[level 1] 문자열 다루기 기본 , isdigit (0) | 2020.07.10 |