Intervals
Medium

Min Arrows to Burst Balloons

Find the minimum number of arrows to burst overlapping balloons.
Problem Understanding

You are given an array of balloons where points[i] = [start, end] represents a balloon. An arrow can be shot up vertically at any x. A balloon is popped if start <= x <= end. An arrow can pop infinite overlapping balloons. Find the minimum number of arrows needed to pop all balloons.

Example:

  • Input: [[10,16],[2,8],[1,6],[7,12]]
  • Output: 2
  • Explanation: Shoot one arrow at x=6 (bursts [2,8], [1,6]). Shoot another at x=11 (bursts [10,16], [7,12]).
Algorithm Strategy

This is a Greedy problem similar to Non-overlapping Intervals. We want to shoot an arrow that pops as many balloons as possible. The best spot is the end of the earliest finishing balloon because that maximizes the chance to catch subsequent balloons.

  1. Sort: Sort balloons by their end coordinate.
  2. Iterate:
    • Initialize arrows = 1. Set endPos to the end of the first balloon.
    • For each subsequent balloon: If its start is greater than endPos, it means the current arrow missed it. We must shoot a new arrow. Increment arrows and update endPos to this new balloon's end.
    • Else (overlap), the current arrow also pops this balloon. Do nothing.
Interactive Visualization
Step 1 / 1

Initializing...

1x
See the Logic in Motion
Stop memorizing code. Unlock the full interactive visualizer to master the logic step-by-step.
Unlock VisualizerPREMIUM FEATURE

Stop Guessing, Start Mastering.

Build the FAANG intuition. Master this pattern with optimized implementations, visual dry runs, and our curated collection of high-yield problems.

Start Your Premium Prep