Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

Balloons are intervals [1,6], [2,8], [7,12], [10,16] on a line. Arrows shot at integer points burst every balloon whose interval contains the point. What is the minimum number of arrows that bursts all balloons?

  1. A. 3
  2. B. 4
  3. C. 1
  4. D. 2

Correct answer: D. 2

Greedy by right endpoint: shoot at 6 (bursting [1,6] and [2,8]) and at 12 (bursting [7,12] and [10,16]). One arrow cannot cover both groups, so 2 is minimal.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic