I mention this case right after the code:
“Note that if the digits of the given number is monotonically increasing from right to left, like 43221 then we won’t perform any operations, which is what we want because this is the highest number obtainable from these digits. There’s no higher number, so we return the given number itself.”
Digits of both 9999 and 10000 are monotonically increasing from right to left.
]]>