Easy C++ code using sort


#1
int i,j,k,n;
n=A.size();
vector<int> v,res;
v=A;
sort(v.begin(),v.end());
res.push_back(-1);

for(i=0,j=n-1;i<n;i++,j--)
{
    if(A[i]!=v[i])
    {   res.clear();
        res.push_back(i);
        break;
    }
}

for(i=0,j=n-1;j>=0;i++,j--)
{
     if(A[j]!=v[j])
    {   //v.clear();
        res.push_back(j);
        break;
    }
}

return res;

}