Next permutation

i am unable to do this problem.
pls tell the correct code.