Error in testcases for next permutation stl

my code is attached below

#include #include using namespace std; int main() { int t; cin>>t; int n; while(t–){ cin>>n; int Arr[100]; for(int i=0;i<n;i++){ cin>>Arr[i]; } next_permutation(Arr,Arr+n); for(int i=0;i<n;i++){ cout<<Arr[i]<<" "; } cout<<endl; } return 0; }

https://ide.codingblocks.com/s/203094 sorry that happened by mistake

your code is absolutely correct, the problem is with your array size which you have chose at max 100 but it is not the case as constrain n <=1000.

Tip:- Always allocate array of size around 10^7 or 10^8, so that these type of problems don’t occur.

1 Like

hold on lemme check once

1 Like

Thank you it worked fine