NEXT PERMUTATION


PLEASE TELL WHAT’S WRONG IN THIS


it should be a[j]
not a[i]

after that it will work

Only the first test case is satisfying

change size of array
modified Code

#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int t;
	cin>>t;
	for(int i=0;i<t;i++)
	{
		int n;
		int a[10000];
		cin>>n;
		for(int j=0;j<n;j++)
		{
			cin>>a[j];
		}
		next_permutation(a,a+n);
		for(int j=0;j<n;j++)
		{
			cout<<a[j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course