class Solution { public: vector<int> plusOne(vector<int>& digits) { vector<int> res; int s= digits.size(); if(s==0) return res; int temp=1; for(int i=s-1;i>=0;i--){ temp += digits[i]; if(temp>9) { res.push_back(temp-10); temp=1; } else { res.push_back(temp); temp = 0; } } if(temp) res.push_back(1); reverse(res.begin(),res.end()); return res; } };