Data Structures & AlgorithmsHardProduct Company SDE · greedy intervals

Problem: What is the greedy choice used in the 'minimum number of arrows to burst balloons' problem?

  1. A. Sort by right endpoint and shoot at the right end of the first balloon
  2. B. Sort by left endpoint and shoot at the leftmost point
  3. C. Shoot at the median balloon
  4. D. Shoot at the origin

Correct answer: A. Sort by right endpoint and shoot at the right end of the first balloon

Sorting by right endpoints and shooting at each unpunctured balloon's right end is optimal by an exchange argument.

More Coding Interview Problems questions

Exams that ask this topic