Golang / Go solution


  • 0
    D
    func plusOne(digits []int) []int {
        var n int = len(digits)
        for i:= n-1; i>=0; i--{
            if digits[i] < 9 {
                digits[i]+=1
                return digits
            } else {
                digits[i] = 0
            }
        }
        var a = make([]int,n+1)
        a[0] = 1
        return a
    
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.