Simple way in c++


#1

vector Solution::subUnsort(vector &A) {
vectora(A.begin(),A.end());
sort(a.begin(),a.end());
int i=0,j=A.size()-1;
while(i<=j){
if(A[i]!=a[i] && A[j]!=a[j])
break;
if(a[i]==A[i])
i++;
if(a[j]==A[j])
j–;
}
if(i>j) return {-1};
return {i,j};
}
`

> indent preformatted text by 4 spaces

`