Why is this code not working?


i am getting all wrong WAs

hello @Parikalp10

sort ur input string before genrating all valid permuations.
doing this will ensure that the all generated strings r in sorted order.

ur updated code->

Thank you. I had one more doubt that why is there not a need to backtrack over here?

just print all strings (valid/invalid both) and observe the pattern.

u will find that all the strings are generated in lexicographical order.

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.