코드
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
int max_idx(char* number, int start, int end) {
int max = start;
for (int i = start; i <= end; i++) {
if (number[i] > number[max])
max = i;
}
return max;
}
char* solution(const char* number, int k) {
int len = strlen((char*)number);
int size = len - k;
char* answer = (char*)calloc(size + 1, 1);
int i = 0, p = 0, x = 0;
x = size - 1;
while (x < len) {
p = max_idx((char*)number, i, x++);
strncat(answer, number + p, 1);
i = p + 1;
}
return answer;
}