Greedy
Make the locally optimal choice at each step to find the global optimum
0/40 solved
Interval Scheduling
Maximize non-overlapping intervals or merge overlapping ones
Approach
Sort intervals by start or end time. Process greedily: for merging, extend current interval if overlapping. For selection, pick intervals that end earliest. For counting overlaps, track active intervals.
How to Recognize
Problem involves intervals with start and end times
Need to merge, count, or select non-overlapping intervals
Phrases like 'merge intervals', 'non-overlapping', 'minimum rooms'
Sort by start or end time is the key first step
Pro Tips
To maximize non-overlapping: sort by end time, greedily pick earliest-ending
To merge: sort by start time, extend end if overlapping
To find minimum platforms/rooms: use sweep line or min-heap approach
8
Total
1
Easy
7
Medium
0
Hard
Time
O(n log n)
Space
O(n)