题目:
题解:
cpp
int* lexicalOrder(int n, int* returnSize){
int *ret = (int *)malloc(sizeof(int) * n);
int number = 1;
for (int i = 0; i < n; i++) {
ret[i] = number;
if (number * 10 <= n) {
number *= 10;
} else {
while (number % 10 == 9 || number + 1 > n) {
number /= 10;
}
number++;
}
}
*returnSize = n;
return ret;
}