class Solution {
public:
vector<int> plusOne(vector<int>& digits) {
//vector<int> res;
reverse(digits.begin(), digits.end());
int ret = 0, curr = 0;
for (int i = 0 ; i < digits.size(); i++){
if( i == 0){
ret = (digits[0] + 1) / 10;
digits[0] = ((digits[0] + 1) < 10) ? digits[0] + 1 : (digits[0] + 1) % 10;
}else{
int t = digits[i];
digits[i] = ((digits[i] + ret) < 10) ? digits[i] + ret : (digits[i] + ret) % 10;
ret = (ret + t) / 10;
}
}
if(ret != 0){
digits.push_back(ret);
}
reverse(digits.begin(), digits.end());
return digits;
}
};