Skip to content

Commit fdf2233

Browse files
authored
Create 3170. Lexicographically Minimum String After Removing Stars1 (#811)
2 parents a222dba + ffdee14 commit fdf2233

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Solution {
2+
public:
3+
void solve(int yes , int n , vector<int> &ans){
4+
if(yes > n){
5+
return;
6+
}
7+
ans.push_back(yes);
8+
9+
for(int i = 0 ; i <= 9 ; i++){
10+
int new_num = yes*10 + i;
11+
if(new_num > n){
12+
return;
13+
}
14+
solve(new_num , n , ans);
15+
}
16+
}
17+
vector<int> lexicalOrder(int n) {
18+
vector<int> ans;
19+
for(int i = 1 ; i <= 9 ; i++){
20+
solve(i , n , ans);
21+
}
22+
23+
return ans;
24+
}
25+
};

0 commit comments

Comments
 (0)