Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
A long, long time ago... solution in Clear category for Merge Intervals (iterator version) by veky
def merge_intervals(intervals):
it = iter(intervals)
a, b = next(it, (None, None))
if a is not None:
for c, d in it:
if c - b >= 2:
yield a, b
a, b = c, d
elif b < d:
b = d
yield a, b
Aug. 28, 2018
Comments: