You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use one end vairable and the begining of each interval to determin all the overlapping intervals. Then count ++.
if there no overlapping interval move end to this end and perform step 1 again.
classSolution(object):
deferaseOverlapIntervals(self, intervals):
""" :type intervals: List[List[int]] :rtype: int """intervals.sort(key=lambdax:x[1])
# max + min = -1 because of 2s complementend=-sys.maxint-1count=0foroneIntervalinintervals:
ifoneInterval[0] <end:
count+=1else:
end=oneInterval[1]
returncount