Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Lists are easier to update solution in Clear category for Merge Intervals by StefanPochmann
def merge_intervals(intervals):
result = []
for start, end in intervals:
if not result or start > result[-1][1] + 1:
result.append([start, end])
result[-1][1] = max(result[-1][1], end)
return list(map(tuple, result))
July 25, 2017
Comments: