Given an array of intervals, find the minimum number of intervals to remove to make the rest non-overlapping.
Greedy: sort by end time. Keep the interval with the earliest end time; remove overlapping ones.
- Sort by end time.
- Greedily keep the first interval (earliest end). Count = 0.
- For each next interval: if it starts >= previous end, keep it (update prevEnd).
- Otherwise, remove it (count++).
- Time Complexity: O(N log N)
- Space Complexity: O(1)