Skip to content

Commit 19b2511

Browse files
authored
Update monotone-increasing-digits.py
1 parent 5cad2d9 commit 19b2511

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Python/monotone-increasing-digits.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
# Time: O(logn) = O(1)
22
# Space: O(logn) = O(1)
33

4+
# Given a non-negative integer N,
5+
# find the largest number that is less than or equal to N with monotone increasing digits.
6+
#
7+
# (Recall that an integer has monotone increasing digits if and only
8+
# if each pair of adjacent digits x and y satisfy x <= y.)
9+
#
10+
# Example 1:
11+
# Input: N = 10
12+
# Output: 9
13+
#
14+
# Example 2:
15+
# Input: N = 1234
16+
# Output: 1234
17+
#
18+
# Example 3:
19+
# Input: N = 332
20+
# Output: 299
21+
#
22+
# Note: N is an integer in the range [0, 10^9].
23+
424
class Solution(object):
525
def monotoneIncreasingDigits(self, N):
626
"""

0 commit comments

Comments
 (0)