C++ binary search
\nclass Solution {\npublic:\n    int findLengthOfShortestSubarray(vector<int>& arr) {\n        int l = 0, r = arr.size() - 1;\n        int ans = 0;\n        for
```\nclass Solution {\npublic:\n    int findLengthOfShortestSubarray(vector<int>& arr) {\n        int l = 0, r = arr.size() - 1;\n        int ans = 0;\n        for(int i = 1; i < arr.size(); ++i) {\n            if(arr[i] >= arr[i - 1]) l = i;\n            else break;\n        }\n        for(int i = arr.size() - 1; i > 0; --i) {\n            if(arr[i] >= arr[i - 1]) r = i - 1;\n            else break;\n        }\n        if(l == arr.size() - 1) return 0;\n        ans = max(max(ans, l + 1), (int)arr.size() - r);\n        vector<int> lv, rv;\n        for(int i = 0; i <= l; ++i) {\n            lv.push_back(arr[i]);\n        }\n        for(int i = r; i < arr.size(); ++i) {\n            int n = arr[i];\n            int lc = upper_bound(lv.begin(), lv.end(), n) - lv.begin();\n            ans = max(ans, lc + (int)arr.size() - i);\n        }\n        return arr.size() - ans;\n    }\n};\n```
[]