← Back to DSA Animator
Minimum Arrows to Burst Balloons LC #452 Medium Intervals · Greedy
Problem

Balloons are [xstart, xend] on the x-axis. An arrow at x bursts all balloons where xstart ≤ x ≤ xend. Return the minimum arrows to burst all balloons.

Example
Input: [[10,16],[2,8],[1,6],[7,12]]
Output: 2
Explanation: Shoot at x=6 (bursts [1,6],[2,8]). Shoot at x=12 (bursts [7,12],[10,16]).
Try Examples
Approach
Greedy — Sort by End, Shoot at Earliest End
Sort by end. Shoot at first balloon's end. All balloons that overlap that point burst. Repeat for next unburst.
Balloons (x-axis)
Load an example to begin.
Arrows 0
Variables
arrowPos
Balloon
In range?
Action
Step Logic
Press ▶ Play or Next Step to begin.
Ready
0 / 0
Select an example and press Play.
Algorithm
1
Sort by end
2
Shoot at first balloon's end
3
If balloon.start > arrowPos → new arrow at balloon.end
Time
O(n log n)
Space
O(1)
Why Shoot at End

Shooting at the end of the first balloon maximizes the chance to hit overlapping balloons. Any balloon with start ≤ arrowPos gets burst. Same logic as Non-Overlapping Intervals.