Minimum Number of Arrows Problem

Minimum Number of Arrows Problem — ExecCode Medium DSA Practice

Solve the Minimum Number of Arrows problem on ExecCode. Free online medium DSA practice in Intervals. Write and run code in Java, C++, Python — no signup required to run.

Problem description

There are balloons on a number line, given as points[i] = [xstart, xend]. An arrow shot straight up at position x bursts every balloon whose range contains x. Return the minimum number of arrows needed to burst every balloon.

Examples

Input points = [[10, 16], [2, 8], [1, 6], [7, 12]]; Output 2. Input points = [[1, 2], [3, 4], [5, 6], [7, 8]]; Output 4. Input points = [[1, 2], [2, 3], [3, 4], [4, 5]]; Output 2

Constraints

1 ≤ points.length ≤ 10⁵ points[i].length == 2 -2³¹ ≤ xstart < xend ≤ 2³¹ - 1

Practice Minimum Number of Arrows free on ExecCode. Browse DSA problems, topic map, and placement guides.