balloons[i] = [left, right] covers the horizontal span from left to right, inclusive; its height does not matter.
A dart is thrown straight up from any point x. It flies forever and pops every balloon with left ≤ x ≤ right.
Return the smallest number of darts that pops every balloon.balloons=[[4, 9], [1, 5], [11, 14], [8, 12]] → 2
A shot at x = 5 pops [1, 5] and [4, 9]; a shot at x = 11 pops [8, 12] and [11, 14].
balloons=[[0, 3], [3, 6], [6, 9]] → 2
Touching an edge counts: x = 3 hits the first two, and the third needs its own shot.
balloons=[[-5, 20], [0, 1], [2, 3]] → 2
[0, 1] and [2, 3] do not overlap, so two shots are needed, and the wide balloon is hit by either.
balloons=[[4, 9], [1, 5], [11, 14], [8, 12]]
2
Run checks the first 3 tests in your browser. Submit checks all 111 tests on the server, hidden ones included.