AC Java Solution


  • 0
    C
        public int[] plusOne(int[] digits) {
            int cur = digits.length - 1;
            while(cur > -1){
                digits[cur]++;
                if(digits[cur] == 10){
                    digits[cur] = 0;
                    cur--;
                }else{
                    return digits;
                }
            }
            
            int[] ans = new int[digits.length + 1];
            ans[0] = 1;
            return ans;
        }

Log in to reply
 

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