★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs.com/strengthen/)➤GitHub地址:https://github.com/strengthen/LeetCode➤原文地址: https://www.cnblogs.com/strengthen/p/10519845.html ➤如果链接不是山青咏芝的博客园地址,则可能是爬取作者的文章。➤原文已修改更新!强烈建议点击原文地址阅读!支持作者!支持原创!★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
Given a non-negative integer N, find the largest number that is less than or equal to Nwith monotone increasing digits.
(Recall that an integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y.)
Example 1:
Input: N = 10 Output: 9Example 2:
Input: N = 1234 Output: 1234Example 3:
Input: N = 332 Output: 299Note: N is an integer in the range [0, 10^9].
给定一个非负整数 N,找出小于或等于 N 的最大的整数,同时这个整数需要满足其各个位数上的数字是单调递增。
(当且仅当每个相邻位数上的数字 x 和 y 满足 x <= y 时,我们称这个整数是单调递增的。)
示例 1:
输入: N = 10 输出: 9示例 2:
输入: N = 1234 输出: 1234示例 3:
输入: N = 332 输出: 299说明: N 是在 [0, 10^9] 范围内的一个整数。
转载于:https://www.cnblogs.com/strengthen/p/10519845.html