 All Problems
Minimum Number of Arrows to Burst Balloons
medium
array
greedy
intervals
amazon
microsoft

There are some spherical balloons taped onto a flat wall. The balloons are represented as a 2D integer array points where points[i] = [xstart, xend] denotes a balloon whose horizontal diameter stretches between xstart and xend.

Arrows can be shot up from the floor. An arrow shot at x bursts all balloons where xstart <= x <= xend.

Return the minimum number of arrows needed to burst all balloons.

Example 1:

Input: points = [[10,16],[2,8],[1,6],[7,12]]
Output: 2

Example 2:

Input: points = [[1,2],[3,4],[5,6],[7,8]]
Output: 4

Constraints:

  • 1 <= points.length <= 10^5
Run to check your code against the sample cases, or submit to run every case