leetcode1272

 1 class Solution:
 2     def removeInterval(self, intervals: List[List[int]], toBeRemoved: List[int]) -> List[List[int]]:
 3         n = len(intervals)
 4         res = []
 5         for i in range(n):
 6             curent = intervals[i]
 7             if curent[1] <= toBeRemoved[0] or curent[0] >= toBeRemoved[1]:
 8                 res.append(curent)
 9             elif current [ 0 ]> = toBeRemoved [ 0 ] and current [ 1 ] <= toBeRemoved [ 1 ]:
 10                  continue 
11              elif current [ 0 ] <= toBeRemoved [ 0 ] and current [ 1 ]> = toBeRemoved [ 1 ]:
 12                  if the current [ 0 ]! = toBeRemoved [ 0 ]
 13                      res.append ([current [ 0 ], toBeRemoved [ 0 ]])
 14                  if toBeRemoved [ 1 ]! = current [ 1 ]:
 15                     res.append ([toBeRemoved [ 1 ], stream [ 1 ]])
 16              elif current [ 0 ] <= toBeRemoved [ 0 ] and current [ 1 ]> = toBeRemoved [ 0 ] and current [ 1 ] <= toBeRemoved [ 1 ] :
 17                  if the current [ 0 ]! = toBeRemoved [ 0 ]
 18                      res.append ([current [ 0 ], toBeRemoved [ 0 ]])
 19              elif current [ 1 ]> = toBeRemoved [ 1 ] and current [ 0] <= toBeRemoved[1] and curent[0] >= toBeRemoved[0]:
20                 if toBeRemoved[1] != curent[1]:
21                     res.append([toBeRemoved[1],curent[1]])
22         return res

In six cases discussed (if statement is the first two cases)

Guess you like

Origin www.cnblogs.com/asenyang/p/11965148.html