Pattern Recognition Drill
Medium Intervals
The Problem
Given intervals, find the minimum number of intervals to remove to make the rest non-overlapping.
What approach would you use?
Think about it before scrolling down.
Sort by end. Greedily keep intervals whose start >= last kept end. Removals = total - kept. O(n log n).
LIS-style on intervals sorted by end. O(n²) — less efficient.
Common Trap
Sort by END time, not start time. Sorting by start can lead to suboptimal greedy choices.