```
public int[] plusOne(int[] digits) {
int n = digits.length;
int carrier = 1;
for (int i = n - 1; i >= 0; i--) {
int tmp = digits[i] + carrier;
digits[i] = tmp % 10;
carrier = tmp / 10;
}
if (carrier == 0)
return digits;
int[] result = new int[n + 1];
result[0] = carrier;
System.arraycopy(digits, 0, result, 1, n);
return result;
}
```