C++ Sliding Window & binary search both approaches
Sliding window Approach:\n\n\nclass Solution {\npublic:\n    int findLengthOfShortestSubarray(vector<int>& arr) {\n        int n=arr.size();\n        if(n<2)\n 
**Sliding window Approach:**\n```\n\nclass Solution {\npublic:\n    int findLengthOfShortestSubarray(vector<int>& arr) {\n        int n=arr.size();\n        if(n<2)\n            return 0;\n        int l,r,i=0,j=0;\n        for( ;i<n-1 && arr[i]<=arr[i+1];i++);\n       \n        l=i;if(i>=n-1)return 0;\n        for( i=n-1;i>0 && arr[i]>=arr[i-1];i--);\n        r=i;\n        int ans=min(n-l-1,r);\n         i=0,j=r;\n        while(i<=l && j<n)\n        {\n            if(arr[i]<=arr[j])\n                i++;\n            else\n                j++;\n            ans=min(j-i,ans);\n        }\n        return ans;\n    }\n};\n```\n\n**Binary Search Approach:**\n```\nclass Solution {\npublic:\n    int findLengthOfShortestSubarray(vector<int>& arr) {\n        int n=arr.size();\n        if(n<2)\n            return 0;\n        int l,r,i=0,j=0;\n        for( ;i<n-1 && arr[i]<=arr[i+1];i++);\n       \n        l=i;if(i>=n-1)return 0;\n        for( i=n-1;i>0 && arr[i]>=arr[i-1];i--);\n        r=i;\n        int ans=n-r;\n         for( i=0;i<=l;i++)\n         {\n             int temp=lower_bound(arr.begin()+r,arr.end(),arr[i])-arr.begin();\n             ans=max(ans,i+1+n-temp);\n         }\n        return n-ans;\n    }\n};\n```
[]