Minimum Number of Arrows to Burst Balloons
Balloons are given as horizontal intervals points[i] = [xstart, xend]. An arrow shot straight up at position x bursts every balloon whose interval contains x (xstart <= x <= xend). Return the minimum number of arrows needed to burst all balloons.
Open official problem prompt ↗Cover a set of intervals with the fewest single points, where each point may pierce any interval that contains it.
Imagine scheduling the fewest inspections so that every guest's stay is checked at least once. You inspect right when the earliest-departing guest is about to leave, catching everyone still present, then wait until someone new arrives after that moment.
- Input
- points = [[10,16],[2,8],[1,6],[7,12]]
- Output
- 2
- Why
- One arrow at x=6 bursts [1,6],[2,8]; another at x=12 bursts [7,12],[10,16].
1 <= points.length <= 10^5points[i].length == 2-2^31 <= xstart <= xend <= 2^31 - 1