Python interview question: merge overlapping intervals

MediumIntervals

Problem

shifts holds a store’s courier shifts [start, end] in hours from the start of the week, in any order. Merge overlapping and touching shifts and return the covered intervals sorted by start, or an empty list if there are no shifts.

def merge_shifts(shifts: list[list[int]]) -> list[list[int]]:

Example

Solve it free

Checked against hidden tests, right in your browser. No sign-up needed.

Skills it tests

More interview questions

All questions