# Program - Given a collection of intervals which are already sorted by start number, merge all overlapping intervals.

## Topic: Program - Given a collection of intervals which are already sorted by start number, merge all overlapping intervals.

Solution

org_intervals = [[1,3],[2,6],[5,10],[11,16],[15,18],[19,22]] i = 0 while i < len(org_intervals)-1: if org_intervals[i+1][0] < org_intervals[i][1]: org_intervals[i][1]=org_intervals[i+1][1] del org_intervals[i+1] i = i - 1 i = i + 1 print(org_intervals)

List all Python Programs