I am failing one test case.Please help me find what’s wrong.
Next permutation challenge
no need to write the condition if(!next_permution())
because if next permutation is not possible
then it give false and change the array to intial stage which is sorted
suppose arr={3,2,1}
then after next permutation arr become {1,2,3} and function returns false;
Modified Code
if you want to ask something about this feel free to ask
i hope this helps
if yes show your response with
and don’t forgot to mark doubt as resolved
But i haven’t initially sorted the array. Do the next permutation function automatically sort the array on returning false?
yes because after last combination
next one will be sorted itself
1 Like