```
class Solution {
public:
vector<int> plusOne(vector<int>& digits) {
int cur = digits.size() - 1;
while (cur >= 0) {
if (digits[cur] == 9) {
digits[cur--] = 0;
}
else
{
digits[cur] += 1;
return digits;
}
}
digits[0] = 1;
digits.push_back(0);
return digits;
}
};
```