class Solution {
public:
vector<int> plusOne(vector<int> &digits) {
bool carry = true;
for(int i=digits.size()1; i >= 0 && carry; i) {
carry = (++digits[i]%=10) == 0;
}
if(carry) {
digits.insert(digits.begin(), 1);
}
return digits;
}
};
My C++ Solution with few lines

@R4GH4V An even clearer version :)
digits[i] = ++digits[i]%10;
if (digits[i] == 0){
carry = 1;
} else {
carry = 0;
}
