0ms java solution


  • 8
    F
    public int[] plusOne(int[] digits) {
        int i = digits.length - 1;
        while(i >= 0){
            if(digits[i] == 9)
                digits[i--] = 0;
            else{
                digits[i]++;
                return digits;
            }
        }
        int[] array = new int[digits.length+1];
        array[0] = 1;
        return array;
    }

  • 0
    1

    Does 0ms means your solution runtime error?


Log in to reply
 

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