Plus One
1 vector<int> plusOne(vector<int> &digits) { 2 // Start typing your C/C++ solution below 3 // DO NOT write int main() function 4 int n = digits.size(); 5 int i,carry=1; 6 for(i = n-1; i >= 0; i--){ 7 if(carry == 0) 8 break; 9 digits[i] += 1; 10 if(digits[i] == 10){ 11 digits[i] = 0; 12 carry = 1; 13 } 14 else 15 carry = 0; 16 } 17 if(carry == 1) 18 digits.insert(digits.begin(), 1); 19 return digits; 20 }