my code is attached below
Error in testcases for next permutation stl
#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; }
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