Minimum Number of Arrows to Burst Balloons

Medium#452sort by end

Balloons hang over a line, each one covering an interval [start, end]. An arrow shot straight up at point x bursts every balloon with start ≤ x ≤ end, even one it only touches at the edge. Find the fewest arrows that burst all the balloons. Our example: [4, 8], [10, 12], [1, 6], [7, 9], [2, 4], [9, 11] — the answer is 3.

input
points: balloons, each [xstart, xend]: it spans the x from xstart to xend, ends included.
returns
The fewest vertical arrows that burst every balloon. An arrow shot at x bursts each balloon with xstart ≤ x ≤ xend.
constraints
  • 1 ≤ points.length ≤ 1000
  • −2³¹ ≤ xstart < xend ≤ 2³¹ − 1
our 13 tests keep to them
examples
Open a test in the tests panel: it shows the input and the expected answer.
/**
 * @param {number[][]} points
 * @return {number}
 */
function findMinArrowShots(points) {

}
Ctrl ↵
format
reset

saved in this browser

13 tests · limit 3 s

Stuck?

See the solution run step by step on our example, then why it works and its complexity.

Watch the walkthrough →

Next: more intervals problems

Pattern “Intervals” →

The problem and its statement belong to LeetCode. Here are our own retelling, example and solution. Patterns Hero is not affiliated with LeetCode.