Next Permutation

Why my next permutation isn’t working??
I’m trying to find the minimum element from the remaining array using stl function but it keeps throwing errors.

Hey @div_yanshu07 :smile:

int min=*min_element(a[j+1],a+n);

    sort(a[j+1],a+n); 

is wrong syntax to use these functions
the correct syntax for temp is

int min=*min_element(a+j+1,a+n);

    sort(a+j+1,a+n); 

Whereas while implementing your implementation it will give you segmentation fault.
If you want to use STL for this problem i would suggest you to use next_permutation, if you don’t know about this function i can provide you with the explanation of this function . It might help you :smile:
Thank you

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.