Only one test case is working

can you edit and tell me where is my mistake ?

https://www.codepile.net/pile/GJ7WOeJx

Hello @premang,

It seems like if you don’t have proper knowledge about this function you are using.
I have corrected your code:

Suggestion:
Please read more about it.
What it does?
What is the returned value?
Link: http://www.cplusplus.com/reference/algorithm/next_permutation/

Hope, this would help.
Give a like if you are satisfied.