forked from Nandinig24/Leetcode-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1291
31 lines (28 loc) · 718 Bytes
/
1291
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
class Solution {
public:
vector<int> sequentialDigits(int low, int high) {
vector<int>v={1,12,123,1234,12345,123456,1234567,12345678,123456789};
vector<int>ans;
for(int i=0;i<v.size();i++){
ans.push_back(v[i]);
int p=9-i;
string e="";
for(int k=0;k<=i;k++){
e+="1";
}
int l=stoi(e);
for(int g=1;g<=9-i-1;g++){
v[i]+=l;
ans.push_back(v[i]);
}
}
for(auto i:ans)
cout<<i<<" ";
vector<int>fin;
for(auto i:ans){
if(i>=low && i<=high)
fin.push_back(i);
}
return fin;
}
};