Skip to content

Commit b82f670

Browse files
committed
Runtime: 0 ms (Top 100.00%) | Memory: 5.9 MB (Top 82.10%)
1 parent 42ea74f commit b82f670

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
// Runtime: 0 ms (Top 100.00%) | Memory: 5.9 MB (Top 82.10%)
12
class Solution {
23
public:
34
int monotoneIncreasingDigits(int n) {
45
if(n < 10) return n;
5-
6+
67
string s = to_string(n);
7-
8+
89
for(int i = s.size() - 2; i >= 0; i--) {
910
if(s[i] > s[i+1]) {
1011
s[i]--;
1112
for(int j = i + 1; j < s.size(); j++) s[j] = '9';
1213
}
1314
}
14-
int ans = stoi(s);
15-
return ans;
15+
int ans = stoi(s);
16+
return ans;
1617
}
1718
};

0 commit comments

Comments
 (0)