You are given a list points, where each element points[i] = [x_start, x_end] represents a balloon whose horizontal diameter spans from x_start to x_end on the x axis. An arrow can be shot vertically at any x coordinate x, and it bursts every balloon satisfying x_start <= x <= x_end.
Return the minimum number of arrows required to burst all balloons.
Constraints:
1≤ points.length ≤105
points[i].length ==2
−231≤ x_start < x_end ≤231−1
Input: points = [[5,9],[1,4],[2,6],[8,10]]-List[List[int]]
Output: 2-int
Explanation: Sorting by end coordinate gives [[1,4],[2,6],[5,9],[8,10]]. Shooting the first arrow at x = 4 bursts [1,4] and [2,6], and shooting the next at x = 9 bursts [5,9] and [8,10], for a total of 2 arrows.
Input: points = [[0,1],[2,3],[4,5],[6,7],[8,9]]-List[List[int]]
Output: 5-int
Explanation: None of the intervals overlap, so no single arrow position can hit more than one balloon. Each balloon needs its own arrow, so the answer is 5.
Input: points = [[-10,-1],[-8,-3],[-6,-2],[-4,0]]-List[List[int]]
Output: 1-int
Explanation: All intervals overlap in the region [-4, -3]. Shooting one arrow at x = -3 (or x = -4) satisfies x_start <= x <= x_end for every balloon, bursting all with 1 arrow.
Input: points = [[-2147483648,-2147483647],[2147483646,2147483647],[-5,5],[6,7]]-List[List[int]]
Output: 4-int
Explanation: These intervals are pairwise non-overlapping ([-5,5] ends before [6,7] starts, and the extreme-range balloons are far away). Since no arrow can hit two balloons at once, each balloon requires its own arrow, giving 4 arrows.
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem: