```
class Solution {
public:
vector<int> lexicalOrder(int n) {
int cnt = 0;
int a = 1;
vector<int> res(n);
while(cnt<n)
{
res[cnt++] = a;
a*=10;
while(a>n)
{
a/=10;
a++;
while(a%10==0) a/=10;
}
}
return res;
}
};
```