Skip to content

Commit d5849f3

Browse files
authored
changed for loop condition
1 parent 7e3edf7 commit d5849f3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: plus_one/plus_one.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package plus_one
22

33
func plusOne(digits []int) []int {
44
carry := 1
5-
for i := len(digits); i >= 0; i++ {
5+
for i := len(digits)-1; i >= 0; i-- {
66
sum := carry + digits[i]
77
if sum < 10 {
88
digits[i] = sum

0 commit comments

Comments
 (0)