一、刷题
1.leetcode题目 738. 单调递增的数字 - 力扣(LeetCode)(medium)
解决:
class Solution:
def monotoneIncreasingDigits(self, n: int) -> int:
list_n = list(str(n))
list_n = [int(i) for i in list_n]
for i in range(len(list_n)-1,0,-1):
if list_n[i]<list_n[i-1]:
list_n[i:] = [9]*(len(list_n) - i)
list_n[i-1] -= 1
res = 0
for i in list_n:
res = res*10 + i
return res