-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_291119.cpp
51 lines (47 loc) · 857 Bytes
/
test_291119.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
vector<int> Solution::plusOne(vector<int> &a) {
int i=0,key=0;
int n=a.size();
a[n-1]=a[n-1]+1;
for(i=1;i<n;i++)
{
if(a[n-i]==10)
{
a[n-i]=0;
a[n-i-1]=a[n-i-1]+1;
}
}
//Increasing size if the first element becomes zero
if(a[0]==10)
{
a[0]=1;
a.resize(a.size()+1);
a[a.size()]=0;
}
//Removing the intial zeros in the input
for(i=0;i<n;i++)
{
if(a[i]==0)
{
continue;
}
else
{
key=i;
break;
}
}
/*for(i=key;i<a.size();i++)
{
cout<<a[i];
}*/
vector<int> b(1000000,0);
int j=0;
for(i=key;i<a.size();i++)
{
b[j]=a[i];
//cout<<b[j];
j++;
}
b.resize(j);
return(b);
}