Skip to content

Commit

Permalink
Create: 66-Plus-One.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Ykhan799 authored Sep 20, 2022
1 parent f1ef51f commit a51d7ca
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions go/66-Plus-One.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
func plusOne(digits []int) []int {
for i := len(digits) - 1; i >= 0; i-- {
if digits[i] < 9 {
digits[i] += 1
return digits
}
digits[i] = 0
}
digits[0] = 1
digits = append(digits, 0)
return digits
}

0 comments on commit a51d7ca

Please sign in to comment.