please help me with the approach
How to even approach this?
@chemant077 Please refer the permutations lecture video which is there in the recursion and backtracking section of your course.This problem is one of its variation.
As you do permutation
just in the base case u simply cout the permutation
in this you only have to check that the permutation is bigger than the original string that is input string or not
if greater then cout the permutation if not then don’nt cout
can we check it witht he help of comparator
Not required…
Say there are 2 strings…: string a, string b
They can be directly compared like this
if(a>b) or
if(a==b) or
if(a<b)
showing wrong answer
Refer this.It is exactly the same approach as prateek bhaiya taught on the lecture video to generate permutations.
can you please how can i edit my code to do the same??
also your code too giving the wrong output
There are lot of errors in your code. I cannot understand why you are using vector of int in the main. You are unneccesararily making it complicated.
@chemant077 Check this if it works. Note that we were supposed to print the outputs in sorted order.
Refer this. I have commented out the steps for your understanding:
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.