1. Sort by End, Count the Removals Optimal
Intuition
Removing the fewest intervals is the same as keeping the most. Of the intervals that compete for the same room, keep the one that ends first: it leaves the most room for the rest. So sort the intervals by end and walk them once, holding the last kept end, which starts below every start. An interval that starts at or after the last kept end overlaps nothing kept: it is kept, and the last kept end becomes its end. An interval that starts before the last kept end overlaps the interval kept last, so it is counted as removed. Sorting by start instead is wrong: on [[2,14],[3,5],[6,8],[9,11]] the long interval [2,14] is kept first and the three short intervals inside it are removed, 3, where removing [2,14] alone is enough. Touching does not overlap: an interval that starts exactly at the last kept end is kept, so the check is greater than or equal. Make it strict and touching counts as overlapping: on [[6,9],[2,4],[8,10],[4,7],[4,6]], the interval [4,6], which starts exactly where [2,4] ends, is removed too, and the answer is 3 instead of 2. Sort by end; remove an interval if it starts before the last kept end.
Algorithm
1. Sort the intervals by end.
2. Start the count of removed intervals at 0, and the last kept end below every start.
3. For each interval, if it starts at or after the last kept end, keep it: the last kept end becomes its end.
4. Otherwise it starts before the last kept end: count it as removed.
5. Return the count.
Time & Space
Time O(n log n) for the sort. Space O(1) besides the sort.