Search RU
Tasks / Algorithms / Merging intervals
Statement medium

Merging intervals

Implement `merge_intervals(intervals)`: merge overlapping intervals.

The input is a list of `[start, end]` pairs in arbitrary order. The output is a
list of `(start, end)` tuples.

Example: `[[1, 3], [2, 6], [8, 10]]` → `[(1, 6), (8, 10)]`.

Touching intervals (`[1, 4]` and `[4, 5]`) count as overlapping.

algorithmssortingintervals
solution.py Python 3.14
AI mentor

The AI mentor is available after you log in: it sees your attempt history and does not spend resources on anonymous requests.

Log in and ask
Hints 1 of 3 unlocked · attempts: 0
Hint 1

What has to happen to the intervals before merging, given that the order is
arbitrary?

Hint 2 — unlocks after 1 attempt
Hint 3 — unlocks after 3 attempts