Sliding window technique with runtime 0ms
Intuition\n Describe your first thoughts on how to solve this problem. \nSliding window technique\n\n# Approach\n Describe your approach to solving the problem.
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSliding window technique\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nfirst select the left part as non decreasing\nthen do the same thing  also for the right part\nnow merge both the part to check if there exists shorter array that can be removed to make the array non decreasing.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n# Code\n```cpp []\nclass Solution {\npublic:\n    int findLengthOfShortestSubarray(vector<int>& arr) {\n        int n=arr.size();\n        int left=0;\n        int right= n-1;\n        while(left < n-1 && arr[left] <= arr[left+1]){\n            left++;\n        }\n        if(left == n-1) return 0;\n\n        while(right > 0 && arr[right] >= arr[right-1]){\n            right--;\n        }\n        int result= min (n-1-left,right); //eliminate right part or left part entirely\n        int i=0, j=right;\n        while(i <= left && j < n){\n            if(arr[i] <= arr[j]){\n                result= min(result, j-i-1);\n                i++;\n            }\n            else{\n                j++;\n            }\n        }\n        return result;\n    }\n};\n```
['C++']