0%
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| class Solution: def findLengthOfShortestSubarray(self, arr: List[int]) -> int: l,r = 0,len(arr)-1 if arr==[] or len(arr)==1: return 0 while l+1<=len(arr)-1 and arr[l]<=arr[l+1]: l += 1 if l==len(arr)-1: return 0 while r-1>=0 and arr[r]>=arr[r-1]: r -= 1 left,right = arr[:l+1],arr[r:] min_lenth = r for i in range(l+1): j = bisect.bisect_left(right,left[i]) min_lenth = min(min_lenth,r+j-i-1) return min_lenth
|