[Python] Simple and concise linear time Solution beats 99.2 %
Intuition :- The question asks us to make the array sorted by removing a subarray. So we can boil down the solution to three steps :- \n1) Find the non decreasi
**Intuition** :- The question asks us to make the array sorted by removing a subarray. So we can boil down the solution to three steps :- \n1) Find the non decreasing subarray from start=0 and remove all part of array after that.\n2) Find the non increasing subarray from end=len(arr)-1 and remove all part of the array before that. \n3) Try to merge the arrays found from start and end and find the maximum increasing subarray. For this we can use two pointer technique.\n```\nclass Solution:\n    def findLengthOfShortestSubarray(self, arr: List[int]) -> int:\n        st = 0\n        end = len(arr) - 1\n        prev = None\n        \n        st = Solution.find_end_subarray(arr=arr, st=0, inc_flag=True)\n        end = Solution.find_end_subarray(arr=arr, st=len(arr)-1, inc_flag=False)\n\n        merge_length = Solution.merge(st-1, end+1, arr)\n        take_first = len(arr) - st\n        take_end = end + 1\n        take_merged = len(arr) - merge_length\n        return min(take_first, min(take_end, take_merged))\n        \n    @staticmethod\n    def find_end_subarray(arr, st, inc_flag, prev=None):\n        while(st < len(arr) if inc_flag else st >= 0):\n            if prev is None or (arr[st] >= prev if inc_flag else arr[st] <= prev):\n                prev = arr[st]\n                st = st + 1 if inc_flag else st - 1\n            else:\n                break\n        return st\n    \n    @staticmethod\n    def merge(first_arr_end, second_arr_st, arr):\n        ans = 0\n        first_arr_st = 0\n        while(first_arr_st <= first_arr_end and second_arr_st < len(arr)):\n            if arr[first_arr_st] <= arr[second_arr_st]:\n                if first_arr_st >= second_arr_st:\n                    ans = max(ans, len(arr) - 1)\n                    break\n                else:\n                    ans = max(ans, first_arr_st + len(arr) - second_arr_st + 1)\n                first_arr_st += 1\n            else:\n                second_arr_st += 1\n        return ans            \n```
['Two Pointers', 'Python3']