Fewest removals to end overlaps
intervals is a list of (start, end) pairs; two touching at an endpoint do not overlap.
Write min_removals(intervals) that returns the fewest intervals to remove so none of
the remaining ones overlap.
min_removals([(1, 2), (2, 3), (3, 4), (1, 3)]) -> 1
min_removals([(1, 2), (1, 2), (1, 2)]) -> 2
min_removals([(1, 2), (2, 3)]) -> 0
The point is to practise seeing a problem as the complement of one you know: keep the most non-overlapping intervals (earliest end first), remove the rest.
def min_removals(intervals):
...