public int[] plusOne(int[] digits) {

    if (digits.length == 0) {
      return digits;
    }

    for (int i = digits.length - 1 ; i >= 0 ; i--) {

      int curt = digits[i];

      if (curt == 9) {
        digits[i] = 0;
        continue;
      } else {
        digits[i] += 1;
        return digits;
      }
    }

    int[] result = new int[digits.length + 1];
    result[0] = 1;
    for (int i = 0 ; i < digits.length ; i++) {
      result[i + 1] = digits[i];
    }
    return result;
  }