Advertisement
jibha

Untitled

Feb 1st, 2022
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. class Solution {
  2. public:
  3.  
  4. vector<int> ans;
  5.  
  6.  
  7. void dfs(int n,int original,int power){
  8.  
  9. if(original<n){
  10. return;
  11. }
  12.  
  13.  
  14. for(int i=1;i<10;i++){
  15. ans.push_back(n);
  16. dfs(i*pow(10,power)+n,original,power+1);
  17. }
  18.  
  19. return;
  20. }
  21.  
  22.  
  23. vector<int> lexicalOrder(int n) {
  24.  
  25. dfs(0,n,0);
  26.  
  27. return ans;
  28. }
  29. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement