public int[] plusOne(int[] digits) {
        if (digits == null || digits.length == 0) {
            return null;
        }
        
        int[] result = new int[digits.length];
        for (int i = digits.length - 1; i >= 0; i--) {
            if (digits[i] < 9) {
                result[i] = digits[i] + 1;
                break;
            }
            else {
                result[i] = 0;
            }
        }
        if (result[0] == 0) {
            int[] tmp = result;
            result = new int[digits.length + 1];
            result[0] = 1;
            System.arraycopy(tmp, 0, result, 1, digits.length);
        }
        return result;
    }