```
public int[] plusOne(int[] digits) {
int cur = digits.length - 1;
while(cur > -1){
digits[cur]++;
if(digits[cur] == 10){
digits[cur] = 0;
cur--;
}else{
return digits;
}
}
int[] ans = new int[digits.length + 1];
ans[0] = 1;
return ans;
}
```