FAANG · LeetCode #452
Minimum Number of Arrows to Burst Balloons — three-stage drill
1The ProblemMedium
Minimum Number of Arrows to Burst Balloons
Min arrows to pop every balloon, where one arrow fired at x bursts every balloon spanning that x.
Examples
[[10,16],[2,8],[1,6],[7,12]]→ 2[[1,10],[2,3],[5,6],[7,8]]→ 3
constraintBalloons are closed intervals [start, end]; an arrow at x bursts every balloon with start ≤ x ≤ end.
2The PatternTIME O(n log n) · SPACE O(n)
Intervals
Given a pile of ranges, sort them by start — now any overlap is a neighbour, so a single left→right pass handles them.
Problems using this pattern
3The SolutionRESULT → 2
Step through it
given: 4 balloons spanning x-ranges · burst all with the fewest arrows
Step 1 / 7
Arrow keys to navigate · escape to reset