[explained][easy understanding][cpp]
\nclass Solution {\npublic:\n    int findLengthOfShortestSubarray(vector<int>& arr) {\n        int l=0, r=arr.size()-1,n=arr.size(); //(l is to count length of 
```\nclass Solution {\npublic:\n    int findLengthOfShortestSubarray(vector<int>& arr) {\n        int l=0, r=arr.size()-1,n=arr.size(); //(l is to count length of leftprefixarray, r is to count length of rightsuffixarray)\n        //the monotone increasing prefix [a[0] <= ... a[i] | ...]\n        while(l < r and arr[l+1] >= arr[l]){\n             l+=1;\n        }\n        //if l=length of array means that whole array is sorted so no need of removing\n        if(l == n-1) return 0;\n        //the monotone increasing suffix [... | a[j] <= ... a[n]]\n        while( r > 0 and arr[r-1] <= arr[r]){\n              r-=1;\n        }\n        int lentoRemove = min((n-l-1), r);\n        // merge 2 sorted arrays, if we can merge, update our minimum to remove.\n        for(int i=0;i<l+1;i++){\n            if(arr[i] <= arr[r])\n                lentoRemove = min(lentoRemove,(r-i-1));\n            else if(r < n-1)\n                r += 1;\n            else\n                break;\n        }\n        return lentoRemove;\n    }\n};\n```\n**Feel free to ask any question in the comment section.**\nI hope that you\'ve found the solution useful.\nIn that case, **please do upvote and encourage me** to on my quest to document all leetcode problems\uD83D\uDE03\nHappy Coding :)\n
['C', 'C++']