mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-01-12 18:08:38 +08:00
routine
This commit is contained in:
16
26/01/go/66.go
Normal file
16
26/01/go/66.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package A
|
||||
|
||||
func plusOne(digits []int) []int {
|
||||
for i := len(digits) - 1; i >= 0; i-- {
|
||||
if digits[i] == 9 {
|
||||
digits[i] = 0
|
||||
if i == 0 {
|
||||
digits = append([]int{1}, digits...)
|
||||
}
|
||||
continue
|
||||
}
|
||||
digits[i]++
|
||||
break
|
||||
}
|
||||
return digits
|
||||
}
|
||||
Reference in New Issue
Block a user