Skip to content

Commit

Permalink
cpp 解法
Browse files Browse the repository at this point in the history
  • Loading branch information
rinwf committed Sep 18, 2018
1 parent cae00b8 commit def2f0d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lc66. Plus One.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Solution {
public:
vector<int> plusOne(vector<int>& digits) {
int length=digits.size();
for(int i=length;i!=0;i--){
if(digits[i-1]!=9) {
digits[i-1]++;
break;
}
else{
digits[i-1]=0;
if(i==1){

digits.insert(digits.begin(),1);
}


}

}
return digits;
}
};

0 comments on commit def2f0d

Please sign in to comment.