Next permutation

sir i am getting wrong answer for my code;
please correct it

Hi @Megha2468, In line 10 you have,

int n,arr[n];
cin>>n; 

Instead , u need to do

int n;
cin>>n;
int arr[n];

So, as you have noticed u are assigning size of array to be n before assigning any value to n
due to which n takes garbage value and assign a random size to arr

i highly suggest you to check the solution after solving the problem

In case of any doubt feel free to ask :slight_smile:
mark your doubt as resolved