Greedy Interval Scheduling

easy
Unit 6 · Matrices0/3 to milestone

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.)

#greedy#intervals#sorting2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Greedy Interval Scheduling · TechGradify