InferenceAI

Enter at least two characters to search.

Start free

Arrows for Balloons

mediumGreedy & Intervals25 min25 XP

Each balloon spans the horizontal interval [start, end]. An arrow shot at xx bursts every balloon with start≤x≤end\text{start} \le x \le \text{end}. Return the minimum number of arrows to burst all balloons.

Examples

EXAMPLE WALKTHROUGHtwo arrows

A guided view of the published example, not a trace of your code.

INPUT[[[10,16],[2,8],[1,6],[7,12]]]
TASKarrows_for_balloons()
EXPECTED OUTPUT2

Start with the input values shown in this example.

Example 1 of 3

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

Output: 2

Explanation: two arrows

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

Output: 4

Explanation: disjoint

Input: points = [[1,2],[2,3],[3,4],[4,5]]

Output: 2

Explanation: touching

Hint 1

Sort by end; shoot at the end of the first balloon and skip every balloon it bursts.

Topics

DSAGreedy & IntervalsPython