Find the minimum number of arrows needed to burst all balloons represented as intervals on a number line.
Minimum Number of Arrows to Burst Balloons
You are given a collection of balloons, where each balloon is represented by an interval on the number line: points[i] = [start, end]. A balloon bursts if an arrow shot at position x satisfies start <= x <= end.
You may shoot an unlimited number of arrows, each at any integer or real position. Return the minimum number of arrows required to burst every balloon.
Two balloons can be burst by the same arrow if their intervals overlap at at least one point.
Input Format
points: an array of intervals[[start1, end1], [start2, end2], ...]- Each interval describes the inclusive range covered by one balloon.
Output Format
- Return a single integer: the minimum number of arrows needed to burst all balloons.
Constraints
1 <= points.lengthstart <= endfor each interval- Balloons are inclusive intervals on a number line
- Exact platform constraints are not guaranteed here; treat the input as standard interval data
Example 1
Input
points = [[10,16],[2,8],[1,6],[7,12]]
Output
2
Explanation
One arrow shot at 6 bursts [2,8] and [1,6]. Another arrow shot at 11 bursts [10,16] and [7,12].
Example 2
Input
points = [[1,2],[3,4],[5,6],[7,8]]
Output
4
Explanation
No balloons overlap, so each balloon needs its own arrow.
Show 1 more example
Example 3
Input
points = [[1,10],[2,3],[4,5],[6,7]]
Output
3
Explanation
An arrow at 3 bursts [1,10] and [2,3], an arrow at 5 bursts [4,5], and an arrow at 7 bursts [6,7].
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.