We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5cad2d9 commit 19b2511Copy full SHA for 19b2511
Python/monotone-increasing-digits.py
@@ -1,6 +1,26 @@
1
# Time: O(logn) = O(1)
2
# Space: O(logn) = O(1)
3
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
+
24
class Solution(object):
25
def monotoneIncreasingDigits(self, N):
26
"""
0 commit comments