[Programmers] 큰 수 만들기

Time Lapse :4hour 0min 0sec

solution.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
using namespace std;

string solution(string number, int k) {
int need = number.length()-k,start = 0, len = number.length();
char max_num;
string answer = "";
while(need){
max_num = number[start];
for(int i=start+1;i<=len-need;i++){
if(max_num<number[i]){
max_num = number[i];
start = i;
}
}
answer += max_num;
--need;
++start;
}
return answer;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/Programmers/buildBigNumber/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.