Two classic greedy problems on closed intervals [start, end]:
max_non_overlapping(intervals): the largest number of intervals you can keep with no two overlapping. Intervals that only touch at an endpoint ([1, 2] and [2, 3]) do overlap here.min_arrows(intervals): balloons span [start, end] on a line. An arrow shot at x bursts every balloon with start <= x <= end. Return the minimum number of arrows that burst them all.Both run in O(n log n). (They turn out to be the same algorithm.)