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 e332190 commit 6994866Copy full SHA for 6994866
problems/0738.单调递增的数字.md
@@ -163,7 +163,30 @@ class Solution:
163
164
Go:
165
166
+Javascript:
167
+```Javascript
168
+var monotoneIncreasingDigits = function(n) {
169
+ n = n.toString()
170
+ n = n.split('').map(item => {
171
+ return +item
172
+ })
173
+ let flag = Infinity
174
+ for(let i = n.length - 1; i > 0; i--) {
175
+ if(n [i - 1] > n[i]) {
176
+ flag = i
177
+ n[i - 1] = n[i - 1] - 1
178
+ n[i] = 9
179
+ }
180
181
+
182
+ for(let i = flag; i < n.length; i++) {
183
184
185
186
+ n = n.join('')
187
+ return +n
188
+};
189
+```
190
191
192
-----------------------
0 commit comments