33 · Intervals

#452 Minimum Number of Arrows to Burst Balloons

Mediumsolve on LeetCode ↗

frequently reported atMicrosoftAmazonGoogle

the problem

In plain words

Each balloon spans [xstart, xend] on the x-axis. A vertical arrow shot at x bursts every balloon with xstart ≤ x ≤ xend. Return the minimum number of arrows that burst all balloons.

in points = [[10,16],[2,8],[1,6],[7,12]]

out 2

An arrow at x = 6 bursts [2,8] and [1,6]; one at x = 11 bursts [10,16] and [7,12].

in points = [[1,2],[3,4],[5,6],[7,8]]

out 4

No two balloons share a point.

in points = [[1,2],[2,3],[3,4],[4,5]]

out 2

Touching counts: x = 2 and x = 4.

  • 1 ≤ points.length ≤ 10⁵
  • −2³¹ ≤ xstart < xend ≤ 2³¹ − 1

your turn

Try it before you peek

Read the examples, say the brute force out loud, then write code: here or on LeetCode ↗. Stuck for 20 minutes? Open one hint at a time.

Solve it in the browser

LeetCode-style: complete the class. Compiled by the real javac (Java 17) and judged right here — nothing is sent anywhere.

    Solutions are hidden so you can try first. Even 20 minutes of real effort makes the answer stick far better than reading it.

    Marking the problem solved, or opening every hint, also shows it.

    practise next

    Similar problems

    1. #435
      Non-overlapping Intervals
      Mediumin Intervals
    2. #56
      Merge Intervals
      Mediumin Intervals