Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions 3170. Lexicographically Minimum String After Removing Stars1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class Solution {
public:
void solve(int yes , int n , vector<int> &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<int> lexicalOrder(int n) {
vector<int> ans;
for(int i = 1 ; i <= 9 ; i++){
solve(i , n , ans);
}

return ans;
}
};
Loading