We use cookies for site analytics. Accept to help us understand how the site is used. See our Privacy Policy for details.
A medium intervals problem, graded against 7 test cases (4 of them hidden).
Sorting by start or end, then merging or scheduling overlapping ranges.
Reach for it when you see: Meetings, bookings, ranges, or anything with a start and an end.
More Intervalsproblems →Sort by start value. Sweeping left to right, each interval either overlaps the most recently merged interval (`start <= mergedEnd`, so extend the end with `max`) or begins a new disjoint block. Sorting guarantees no later interval can overlap an already-closed block.
The full reference solution in every supported language stays in the editor above - reveal it there once you have had a real attempt.
Read off this problem's own test suite, so these are the cases a submission actually has to survive.
These apply to the pattern as a whole, not just this problem.