Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First, break down and second, build back solution in Clear category for Merge Intervals by Tinus_Trotyl
def merge_intervals(intvls):
result = []
while intvls:
while intvls[1:] and intvls[0][1] + 1 >= intvls[1][0]:
intvls = [(min(intvls[0][0], intvls[1][0]), max(intvls[0][1], intvls[1][1]))] + intvls[2:]
if intvls: result, intvls = result + intvls[:1], intvls[1:]
return result
July 29, 2017
Comments: