python - two pointers - with comments
python\nclass Solution(object):\n    def findLengthOfShortestSubarray(self, arr):\n        """\n        :type arr: List[int]\n        :rtype: int\n        """\n
```python\nclass Solution(object):\n    def findLengthOfShortestSubarray(self, arr):\n        """\n        :type arr: List[int]\n        :rtype: int\n        """\n        l = len(arr)\n        low, high = 0, l - 1\n        # "low" is the index of first element which made the array unsorted (left to right).\n        while (low < l - 1 and arr[low] <= arr[low + 1]):\n            low += 1\n        if low == l - 1:  # if the array is sorted\n            return 0\n        # "high" is the index of the element that make the array unsorted (right to left)\n        while (high > 0 and arr[high] >= arr[high - 1]):\n            high -= 1\n        # We have to remove anything in between low and high. \n        # there are three cases we can consider\n        ####--------     -----####\n        ###|    low|    |high   |#\n        # First case : keeping right elements, removing "high" number of elements\n        # Second case: keeping left elements, removing l - (low + 1) elements.\n        subarr_len = min((l - (low + 1) ), high)\n        # Third case: we keep some elements from both left and right sections\n        # for each element at left we shrink the right section untill we can connect\n        # both sections. The elements we have to remove will be between these two pointers.\n        # we set the right pointer to high and iterate over the left one.\n        right = high\n        for left in range(low + 1):\n            # For each element at left shrink the right \n            # window till you find the first element which is \n            # larget than the right one, \n            # e.g. if all elements of left are smaller than\n            # all elements of right the right window will not be shrinked.\n            while right < l and arr[left] > arr[right]:\n                right += 1\n            # the right search space is empty which is equal to the \n            # case we considered before\n            if right == l:\n                break\n            # in new candidate subarray there are left + 1 elements\n            # from the left subarray and \n            subarr_len = min(subarr_len, right - left -1)\n        return subarr_len\n\n\n```
['Two Pointers', 'Python']