题目
代码语言:javascript复制class Solution {
public:
int ans[10005];
vector<int> sequentialDigits(int low, int high) {
int x = 1;
int pos=0;
int tag=1;
for(int i=1;i<=9;i )
{
x=fun2(x);
tag*=10;
int xx=x;
for(int j=1;j<=9-i;j )
{
ans[pos ]=xx;
xx=fun(xx,tag);
}
}
vector<int> res;
int tag2=0;
for(int i=0;i<pos;i )
{
if(ans[i]>=low&&ans[i]<=high)
{
res.push_back(ans[i]);
}
}
return res;
}
int fun(int x,int num)
{
int y =x;
x%=num;
x*=10;
x =y 1;
return x;
}
int fun2(int x)
{
int y = x;
x*=10;
x =y 1;
return x;
}
};