Next permutation

it prints for all cases except one when all permutation get finished it should print first. Not getting that.

hello @coder_girl could you please elaborate your doubt .i didn’t get you

check my code when n=3 2 1 it should print 1 2 3
but its printing 3 2 1

hello @coder_girl please check your code now :


if you have any doubt you can ask here .
Happy Learning !!

when while loop terminates that time k=-1
then how it will going in if block

Now its not passing any test cases

where you are trying to submit it ?
please share the link .

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.