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 a08d7a3 commit fbb0ab6Copy full SHA for fbb0ab6
Algorithms/0066.plus-one/README.md
@@ -9,7 +9,7 @@ The digits are stored such that the most significant digit is at the head of the
9
10
## 解题思路
11
12
-
+见程序注释
13
## 总结
14
15
Algorithms/0066.plus-one/plus-one.go
@@ -6,8 +6,10 @@ func plusOne(digits []int) []int {
6
return []int{1}
7
}
8
+ // 末尾加一
digits[length-1]++
+ // 处理进位
for i := length - 1; i > 0; i-- {
if digits[i] < 10 {
break
@@ -16,6 +18,7 @@ func plusOne(digits []int) []int {
16
18
digits[i-1]++
17
19
20
21
+ // 处理首位的进位
22
if digits[0] > 9 {
23
digits[0] -= 10
24
digits = append([]int{1}, digits...)
0 commit comments