class Solution {
public:
vector<int> plusOne(vector<int> &digits) {
int len = digits.size();
if(digits[len1] < 9){
digits[len1]++;
return digits;
}
for(int i=len1;i>=0;i){
if(digits[i] != 9){
digits[i]++;
return digits;
}
digits[i] = 0;
}
digits.insert(digits.begin(), 1);
return digits;
}
};
Here's my O(n) time solution


Thanks for your post. However it would be better to share solution with correct code format and elaborated thoughts. Please read the Discuss FAQ for more info. Take a look at good sharing example