void itoa(int num, char* str, int* strSize)
{
*strSize = 0;
while (num > 0)
{
str[(*strSize)++] = num%10 + '0';
num /= 10;
}
for (int i=0; i<(*strSize)/2; i++)
{
int tmp = str[i];
str[i] = str[(*strSize) - 1 - i];
str[(*strSize) - 1 - i] = tmp;
}
}
int monotoneIncreasingDigits(int n){
int strSize;
char str[11];
itoa(n, str, &strSize);
int i = 1;
while (i < strSize && str[i - 1] <= str[i])
{
i += 1;
}
if (i < strSize)
{
while (i > 0 && str[i-1] > str[i])
{
str[i - 1] -= 1;
i -= 1;
}
for (i += 1; i < strSize; i++)
{
一刷放过