Given a number represented as an array of digits, plus one to the number.
class Solution { public: vector<int> plusOne(vector<int> &digits) { // Start typing your C/C++ solution below // DO NOT write int main() function bool carry=true; vector<int> ret; ret.resize(digits.size()); for(int i=digits.size()-1;i>=0;i--){ ret[i]=digits[i]; if(carry){ ret[i]++; } if(ret[i]>9){ ret[i]=ret[i]-10; carry=true; } else carry=false; } if(carry){ //ret.push_back(1); ret.insert(ret.begin(),1); } return ret; } };