Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Merge Intervals by Phil15
def merge_intervals(intervals):
res = []
for s, e in intervals:
if res and s <= res[-1][1] + 1:
res[-1] = res[-1][0], max(res[-1][1], e)
else:
res.append((s, e))
return res
Feb. 28, 2020
Comments: