> For the complete documentation index, see [llms.txt](https://blog.yushunchen.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blog.yushunchen.com/algo/array/plus-one.md).

# Plus One

{% embed url="<https://leetcode.com/problems/plus-one/>" %}

## Solution 1

```go
func plusOne(digits []int) []int {
    for i := len(digits)-1; i >= 0; i-- {
        digits[i]++
        if digits[i] != 10 {
            return digits
        }
        digits[i] = 0
    }
    digits[0] = 1
    digits = append(digits, 0)
    return digits
}
```
