learn from your code a lot


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

Log in to reply
 

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