Coalesce Busy Blocks
Merge overlapping busy blocks with the sort-and-merge template, keeping touching half-open blocks apart.
The problem
Implement coalesce_busy_blocks(blocks). Each block is a busy time [start, end) with start < end: it includes start but not end. Merge every group of blocks that share some time, and return the merged blocks as new [start, end] lists sorted by start. Blocks that only touch, such as [1, 3) and [3, 5), share no time, so they stay separate. The input can be empty and in any order. Do not change the input list or the blocks inside it.
Starter code
def coalesce_busy_blocks(blocks):
passPublic examples
blocks = [[5, 8], [1, 4], [3, 6], [8, 10]]gives[[1, 8], [8, 10]]blocks = [[1, 9], [2, 3], [4, 8]]gives[[1, 9]]
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
