From ffdee14d0aa5e9c42ec1ebfdb98959d4c2d15e21 Mon Sep 17 00:00:00 2001 From: chayan das Date: Sun, 8 Jun 2025 14:17:33 +0530 Subject: [PATCH] Create 3170. Lexicographically Minimum String After Removing Stars1 --- ...cally Minimum String After Removing Stars1 | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 3170. Lexicographically Minimum String After Removing Stars1 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; + } +};