mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-07 07:35:35 +08:00
update 0738.单调递增的数字: 修改 go 代码处markdown语法错误
This commit is contained in:
@ -179,7 +179,7 @@ class Solution:
|
||||
```
|
||||
|
||||
### Go
|
||||
```golang
|
||||
```go
|
||||
func monotoneIncreasingDigits(N int) int {
|
||||
s := strconv.Itoa(N)//将数字转为字符串,方便使用下标
|
||||
ss := []byte(s)//将字符串转为byte数组,方便更改。
|
||||
@ -187,10 +187,10 @@ func monotoneIncreasingDigits(N int) int {
|
||||
if n <= 1 {
|
||||
return N
|
||||
}
|
||||
for i:=n-1 ; i>0; i-- {
|
||||
if ss[i-1] > ss[i] {//前一个大于后一位,前一位减1,后面的全部置为9
|
||||
for i := n-1; i > 0; i-- {
|
||||
if ss[i-1] > ss[i] { //前一个大于后一位,前一位减1,后面的全部置为9
|
||||
ss[i-1] -= 1
|
||||
for j := i ; j < n; j++ {//后面的全部置为9
|
||||
for j := i; j < n; j++ { //后面的全部置为9
|
||||
ss[j] = '9'
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user