First I check if the last digit is 9. In this test case, it is not, so it should just increment the 0 by 1 and end the program. I don't why leetcode says I have runntime error. I also tried this problem in visual studio without any runtime issue. Can someone please help me? Thanks

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

int s = digits.size();

if (digits.back() == 9){

digits.back() = 0;

digits[s - 2]++;

int i = 2;

while(digits[s -i] == 0){

digits[s - (++i)]++;

}

}

else{

digits[s-1]++;

}

return digits;

}