diff --git a/3170. Lexicographically Minimum String After Removing Stars1 b/3170. Lexicographically Minimum String After Removing Stars1 new file mode 100644 index 0000000..8ac594d --- /dev/null +++ b/3170. Lexicographically Minimum String After Removing Stars1 @@ -0,0 +1,25 @@ +class Solution { +public: + void solve(int yes , int n , vector &ans){ + if(yes > n){ + return; + } + ans.push_back(yes); + + for(int i = 0 ; i <= 9 ; i++){ + int new_num = yes*10 + i; + if(new_num > n){ + return; + } + solve(new_num , n , ans); + } + } + vector lexicalOrder(int n) { + vector ans; + for(int i = 1 ; i <= 9 ; i++){ + solve(i , n , ans); + } + + return ans; + } +};