class Solution {

public:

vector<int> plusOne(vector<int> &digits) {

if(digits.size() == 0)

return digits;

int size = digits.size();

int i;

for(i = size-1; i >= 0; i--){

if(digits[i] == 9){

digits[i] = 0;

}

else

break;

}

if(i == 0){

vector<int>::iterator iter = digits.begin();

iter = digits.insert ( iter , 1 );

}

else

digits[i]++;

return digits;

}

};