Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- vector<int> plusOne(vector<int>& digits) {
- string s="";
- int n=digits.size();
- for(int i=n-1;i>=0;i--)
- {
- if(digits[i]<9)
- {
- digits[i]++ ;
- return digits;
- }
- else
- {
- digits[i]=0;
- }
- }
- //declaring array with n+1 size and each element as 0
- vector<int>v(n+1,0);
- v[0]=1;
- return v;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment