vector<int> Solution::subUnsort(vector<int> &A){ int n = A.size(), l = n, r = -1; for(int i = 0; i < n; i++) { if(i and A[i] < A[i - 1]) { l = min(l, i - 1); r = max(r, i); while(l >= 0and A[l] > A[i]) l--; } if(i + 1 < n and A[i] > A[i + 1]) { l = min(l, i); r = max(r, i + 1); while(r < n and A[r] < A[i]) r++; } } if(l == n) return {-1}; return {l + 1, r - 1}; }