Python O(n)
\nclass Solution:\n    def findLengthOfShortestSubarray(self, arr: List[int]) -> int:\n        n = len(arr)\n        left, right = 1, 1\n        \n        \n   
```\nclass Solution:\n    def findLengthOfShortestSubarray(self, arr: List[int]) -> int:\n        n = len(arr)\n        left, right = 1, 1\n        \n        \n        i = 1\n        while i < n and arr[i] >= arr[i - 1]:\n            left += 1\n            i += 1\n        \n        \n        i = n - 2\n        while i > -1 and arr[i] <= arr[i +1]:\n            right += 1\n            i -= 1\n        \n        \n        l1, l2 = right, left\n        \n        i = n - right\n        while i < n and arr[i] < arr[left - 1]:\n            i += 1\n            l1 -= 1\n            \n            \n        i = left - 1\n        while i > -1 and arr[i] > arr[n - right]:\n            i -= 1\n            l2 -= 1\n            \n        return max(min(n - left - l1, n - right - l2), 0)\n```\n
['Python3']