1 class Solution(object): 2 def videoStitching(self, clips: ‘List[List[int]]‘, T: int) -> int: 3 li = sorted(clips, key = lambda x: (x[0],x[1])) 4 #print(li) 5 lens = len(li) 6 if li[0][0]!=0: 7 return -1 8 if li[lens-1][1]<T: 9 return -1 10 count = 0 11 basetag = 0 12 i = 0 13 while i < len(li): 14 if li[i][0]<=basetag: 15 if li[i][1]>=T: 16 return count + 1 17 else: 18 i += 1 19 else: 20 count += 1 21 basetag = li[i-1][1] 22 if basetag >= T: 23 return count 24 25 count += 1 26 return count
原文:https://www.cnblogs.com/asenyang/p/10666678.html