```
public int[] plusOne(int[] digits) {
int i=digits.length;
boolean one = true;
while (--i >= 0 && one) {
digits[i]++;
one = digits[i] == 10;
if (one) digits[i] = 0;
}
if (one) {
digits = new int[digits.length+1];
digits[0] = 1;
}
return digits;
}
```