```
public int[] plusOne(int[] digits) {
int j = digits.length-1;
int[] result = new int[digits.length+1];
boolean[] notation = new boolean[digits.length];
while(j>=0) {
if(digits[j] == 9) {
notation[j] = true;
digits[j--] = 0;
}else {
digits[j]++;
break;
}
}
if(notation[0] == false) {
return digits;
}else {
result[0] = 1;
for(int i = 1;i<result.length;i++) {
result[i] = digits[i-1];
}
return result;
}
}
```