738. Monotone Increasing Digits
solution
class Solution:
def monotoneIncreasingDigits(self, n: int) -> int:
for i in range(n, 0, -1):
if self.check_mono(i):
return i
return 0
def check_mono(self, num):
m = 10
while num > 0:
x = num % 10
if m >= x:
m = x
else:
return False
num = num // 10
return Truefollow up
Last updated