Easy java solution


  • 4
    L
     public int[] plusOne(int[] digits) {
        int i=digits.length-1;
        for(;i>=0;i--){
            digits[i]=digits[i]+1;
            if(digits[i]==10) digits[i]=0;
            else return digits;
        }
        int [] result=new int[digits.length+1];
        result[0]=1;
        return result;
    }

Log in to reply
 

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