Next permutation test cases not passing

sir i have made the code for next permutation and it is passing the sample case. but it is not passing the test cases so please check my code and tell my mistake .

hello @tejuschaturvedi0

check now->

Sur why we added space in output but not in input as bith have sane format.

cout dont add space on its own ,its our responsibility to add space explicitly.

in input space is given , cin use this space to decide where previos number ends

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.