import "strconv"
func monotoneIncreasingDigits(n int) int {
str := strconv.Itoa(n)
nums := \[\]byte(str)
length := len(nums)
if length <= 1 {
return n
}
for i := length - 1; i > 0; i-- {
//如果前一个数字比当前值大,说明不是单调递增的,把前一个数字减1,之后所有数字变成9
if numsi-1 > numsi {
numsi-1--
for j := i; j < length; j++ {
numsj = '9'
}
}
}
res, _ := strconv.Atoi(string(nums))
return res
}