C++ O(n) merging left and right sequences (inner loop O(n)) 108ms
\nclass Solution { // frash\npublic: // check [1,2,3,10,0,7,8,9] as well\n    int findLengthOfShortestSubarray(vector<int>& arr) {\n        int az = arr.size(),
```\nclass Solution { // frash\npublic: // check [1,2,3,10,0,7,8,9] as well\n    int findLengthOfShortestSubarray(vector<int>& arr) {\n        int az = arr.size(), l = 0, r = az - 1;\n        while (r > 0 && arr[r - 1] <= arr[r]) r--; // Right-side sequence\n        int ans = r; // If all right-side should be removed\n        while (l < r && (l == 0 || arr[l - 1] <= arr[l])) { // Merging the sequences from left and right\n            while (r < az && arr[r] < arr[l]) r++; // Independent of the outer loop changes at most O(n)\n            ans = min(ans, r - l - 1);\n            l++;\n        }\n        return ans;\n    }\n};\n```
['C++']