Python3 | O(n) Time complexity | Two pointers
Cases:\n1. Remove left side:\n\t- eg. nums = [5,1, 3, 6] -> Remove nums[0:1] = [5]\n2. Remove right side:\n\t- eg. nums = [5, 6, 1, 0] -> Remove nums[2:] = [1, 
Cases:\n1. Remove left side:\n\t- eg. nums = [5,1, 3, 6] -> Remove nums[0:1] = [5]\n2. Remove right side:\n\t- eg. nums = [5, 6, 1, 0] -> Remove nums[2:] = [1, 0]\n3. Remove middle:\n    - eg. nums = [1, 2, 3, 6, 4, 5] -> Remove nums[3:4] = [6]\n4. Remove nothing:\n\t- eg. nums = [1,2,3] -> Remove nothing\n```\nclass Solution:\n    def findLengthOfShortestSubarray(self, arr: List[int]) -> int:\n        # sentinel\n        arr.append(float("inf"))\n        arr.insert(0, 0)\n        \n        left = 0\n        right = len(arr) - 1\n        shortest = float("inf")\n        # find longest ascending array at left side.\n        while left < len(arr) - 2 and arr[left] <= arr[left + 1]:\n            left += 1\n            \n        # [0, 1, 2, 3, 10, 4, 2, 3, 5, \u221E]\n        #               \u2191              \n        #             left           \n        \n        # move right pointer while moving left pointer.\n        while left >= 0:\n            while right - 1 > left and arr[right - 1] >= arr[left] and arr[right] >= arr[right - 1]:\n                right -= 1\n            shortest = min(shortest, right - left - 1)\n            left -= 1\n            \n        # [0, 1, 2, 3, 10, 4, 2, 3, 5, \u221E]\n        #               \u2191              \u2191\n        #             left           right  -> length = 4\n        #   \n        # [0, 1, 2, 3, 10, 4, 2, 3, 5, \u221E]\n        #           \u2191            \u2191\n        #          left        right        -> length = 3\n        #\n        # [0, 1, 2, 3, 10, 4, 2, 3, 5, \u221E]\n        #        \u2191            \u2191\n        #       left        right           -> length = 3\n        #\n        # [0, 1, 2, 3, 10, 4, 2, 3, 5, \u221E]\n        #        \u2191            \u2191\n        #       left        right           -> length = 3\n        #\n        # [0, 1, 2, 3, 10, 4, 2, 3, 5, \u221E]\n        #     \u2191               \u2191\n        #    left           right           -> length = 4\n        #\n        # [0, 1, 2, 3, 10, 4, 2, 3, 5, \u221E]\n        #  \u2191                  \u2191\n        # left              right           -> length = 5\n            \n        return shortest\n        \n```
['Two Pointers', 'Python3']