classSolution { public: conststaticint maxn = 1e5 + 10; conststaticint maxm = 1e5 + 10; conststaticint INF = 0x3f3f3f3f; intfindLengthOfShortestSubarray(vector<int> &arr) { int n = arr.size(); int l = 0, r = n - 1; while (l + 1 < n && arr[l + 1] >= arr[l]) l++; while (r - 1 >= 0 && arr[r - 1] <= arr[r]) r--; if (r <= l) return0; int ans = n; ans = min(r, n - l - 1); if (arr[r] >= arr[l]) { ans = min(ans, r - l - 1); } for (int i = 0; i <= l; ++i) { while(r < n && arr[r] < arr[i]) r++; if (r != n) ans = min(ans, r - i - 1); elsebreak; } return ans; } };