Next permutation

I am unable to do this problem. Pls tell the code.

pls tell the code for this problem

I am suggesting you an approach, please try to implement it yourself.
image

if you dont get any p in the first step… that is the corner case… you just need to reverse the array and print it.

thanks

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.

pls tell in the form of a code.

@yutikakhanna hey,here is code for reference:

updated code: https://ide.codingblocks.com/s/219374

thanks

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.