```
public class Solution {
public int[] plusOne(int[] digits) {
int carry = 0;
digits[digits.length-1] += 1;
for (int i=digits.length-1; i>=0; i--) {
if (digits[i]+carry == 10) {
digits[i] = 0;
carry = 1;
} else {
digits[i] += carry;
carry = 0;
}
}
if (carry !=0) {
int [] ugh = new int[digits.length+1];
ugh[0] = carry;
for (int j =0; j<digits.length; j++) {
ugh[j+1] = digits[j];
}
return ugh;
}
return digits;
}
}
```