Loading problem...
Imagine a carnival game where floating targets are arranged along a horizontal track. Each target is represented by a one-dimensional segment defined by its starting position and ending position along the track. A dart can be thrown at any specific position along the track, and it travels perfectly vertically, popping any target whose segment includes that position.
More formally, you are given a 2D integer array intervals where intervals[i] = [start<sub>i</sub>, end<sub>i</sub>] represents a target spanning from position start<sub>i</sub> to position end<sub>i</sub> (inclusive). A dart thrown at position x pops all targets where start<sub>i</sub> ≤ x ≤ end<sub>i</sub>.
Your goal is to determine the minimum number of darts required to pop every single target. There is no limit on how many darts you can use, and each dart pops all targets along its vertical path.
This is fundamentally an interval coverage optimization problem: find the minimum number of points (dart positions) such that every interval contains at least one of the chosen points.
points = [[10,16],[2,8],[1,6],[7,12]]2All targets can be popped with just 2 darts:
points = [[1,2],[3,4],[5,6],[7,8]]4No two targets share any overlapping positions. Each target forms a completely disjoint interval:
points = [[1,2],[2,3],[3,4],[4,5]]2Adjacent targets share boundary positions, allowing efficient coverage:
Constraints