Short C# Solution


  • 0
    R
        public int[] PlusOne(int[] digits) {
            for(int i = digits.Length-1; i >= 0; i--)      
                if(++digits[i] < 10)
                    return digits;
                else
                    digits[i] -= 10;
            
            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.