```
public class Solution {
List<Integer> res;
public List<Integer> lexicalOrder(int n) {
res = new ArrayList<>();
dfs(0,n);
return res;
}
public void dfs(int num, int n){
if(num>n) return;
for(int i = num;i<=n&&i<num+10;i++){
if(i == 0) continue;
res.add(i);
dfs(i*10, n);
}
}
}
```