Balloons are [xstart, xend] on the x-axis. An arrow at x bursts all balloons where xstart ≤ x ≤ xend. Return the minimum arrows to burst all balloons.
[[10,16],[2,8],[1,6],[7,12]]2endballoon.start > arrowPos → new arrow at balloon.endShooting at the end of the first balloon maximizes the chance to hit overlapping balloons. Any balloon with start ≤ arrowPos gets burst. Same logic as Non-Overlapping Intervals.
Trying arrow positions everywhere is far too slow. Shooting at the end of a balloon hits the most others.
Sort the balloons by their end. Shoot an arrow at the end of the first balloon that is still whole. Every balloon that starts at or before that point bursts too.
Sort by end, and shoot at the end. One arrow covers every balloon that starts before it.
Run the animation above on your own input, or watch the 1:11 video explanation of Minimum Number of Arrows to Burst Balloons with a dry run and Java code.