Recursion Dictionary Order (Larger)

To generate higher permutations, I used this piece of code:-

where I found out the next permutation and used recursion after that,

THE PROBLEM is in 1 of the test case I’m getting error.
In rest 3 test cases it got success.
please help me out!!

in the editorial, t_complexity of solution is O(NN!) in normal case but mine will have O(NN!) in the worst case only.

why is it getting error in one of the test case?

this i/p
qwertyuio

this is giving run time error

I know , that’s what i’m asking why??? i’m getting error

what is the logic that u are using to create all permutation of string ??
can u please explain the 2 for loops and then recursion ??

2 for loops are for finding the next_permutation and then with the help of recursion, i’m doing it for over and over again

@Rhinorox
why dont u go for the simple code of forming all permutation
and store all the resultant perumtation in array and then sort
and then just print those greater than present input
refer to my code once

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.