What is theerror in my code


#1

I’m not getting what’s the error int this ,any help will be appreciated.
vector Solution::nextPermutation(vector &a) {
int i,j,k,l,n;n=a.size();k=n-1;
for(i=n-2;i>=0;i++)
{
if(a[i+1]<a[k])
k=i+1;
if(a[i]<a[i+1])
{
swap(a[i],a[k]);sort(a.begin()+i+1,a.end());
return a;
}
}
sort(a.begin(),a.end());
return a;
}


#2

Look here Click