Easy · Sort Intervals
Understand → Visualise → Practice.
After meetings are ordered by start time, any overlap must appear between adjacent intervals.
Sort intervals, then check whether each start is earlier than the previous end.
Order by starting time.
current.start < previous.end means overlap.
No adjacent conflict means the whole schedule works.
O(n log n) time for sorting and O(n) or O(1) extra space depending on the sort.
Back-to-back meetings such as [1, 2] and [2, 3] do not overlap.
Read the full guide first: Greedy Algorithms and Interval Patterns.
Guest mode lets you understand, visualise and run the sample tests. Create a free account to submit and save your solutions.