Easy Binary Search Approach
We know that our solution is going to lie in range [0, N) N- size of array\np[i] can be 1 or 0 if 1 it indicates that (prefix) array[0,...,i] is non-decreasing 
We know that our solution is going to lie in range [0, N) N- size of array\np[i] can be 1 or 0 if 1 it indicates that (prefix) array[0,...,i] is non-decreasing \ns[i] can be 1 or 0 if 1 it indicates that (suffic) array[i,..n-1] is non-decreasing.\nso we binary search over the range of values the size of window can take.\n\nSo when we want to remove a window of size w then we look at all possible subarrays of size w. So any subarray of form a[i,....,i+w-1] can be removed and we check if on removal of that subarray(window) the remaining array segments when combined together are non-decreasing or not. The remaining array will be non-dec iff -\n1. if left segment itself is non-decreasing or empty\n2. right segment itself is non-decreasing or empty\n3. rightmost element of left segment <= leftmost element of right segment\n\nIf all 3 conditions are satisfied then we can return that by removing a subarray of size w we can get non-dec array. It is possible that actual min subarray may be smaller than w so we check for smaller windows. We look for window size smaller than middle size.\nIf by removing all possible windows of size w we never get a non-dec array that means we need to extend the window size. So we check for elements right of middle element\n\n\n\n```\n#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\nclass Solution {\n    vector<int> p,s;\npublic:\n    bool check(vector<int>& a,int w){\n        int i,flg=0,n=a.size()-1;\n\t\t// left segment is empty and the entire remaining suffix is non-dec\n        if(s[w])\n            return 1;\n\t\t\n\t\t// both left and right segments are non-empty \n        for(i=w;i<n;i++)\n            if(p[i-w] and s[i+1] and a[i-w]<=a[i+1])\n                return 1;\n\t\t\t\t\n\t\t// right segment is empty then we need to check if left part is non-dec\n        return p[n-w];\n    }\n    \n    int findLengthOfShortestSubarray(vector<int>& a) {\n        IOS;\n        int i,n=a.size(),l=0,h;\n\n        h=n-1;\n        p.resize(n,0);\n        s.resize(n,0);\n        \n        p[0]=1;\n        s[n-1]=1;\n        \n        for(i=1;i<n;i++){\n            if(a[i]<a[i-1])\n                break;\n            p[i]=1;\n        }\n        \n        for(i=n-2;i>=0;i--){\n            if(a[i]>a[i+1])\n                break;\n            s[i]=1;\n        }        \n        \n\t\t// binary search over the possible range of window-sizes\n        while(l<=h){\n            int m=l+(h-l)/2;\n            if(check(a,m))\n                h=m-1;\n            else\n                l=m+1;\n        }\n        \n        return l;\n    }\n};\n```
['Binary Search', 'C', 'C++']