Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings

The Balloon Line

Learn
Play
Prove
Problem context and objectives
Mission briefing

Puzzle systems engineer · A game mechanic is behaving incorrectly

Cover maximum spans with minimum points: The Balloon Line.

Brute force may pass the demo but fail when the world fills with players.

How you win

  1. 1Recognize when Greedy interval stabbing matches the clues
  2. 2Keep this true after every move: the latest arrow sits at the earliest end among all balloons it covers
  3. 3Reach the result within O(n log n)

Rules and pressure

  • Target cost: O(n log n)
  • State rule: the latest arrow sits at the earliest end among all balloons it covers
Lesson 1 of 3

Live algorithm trace

Greedy interval stabbing

Complete execution
1 of 6

Sort balloons by their right endpoints.

1sort balloons by end
2arrows = 0
3if start > lastArrow
4shoot at current end
5return arrows
arrows = 0lastArrow = none
Truth to preserve / Cost target
Truth to preserve

the latest arrow sits at the earliest end among all balloons it covers

Cost target

O(n log n)

Sort balloons by their right endpoint. Shoot at the earliest end; that point bursts every overlapping balloon while preserving the greatest possible reach into future intervals.

Your call · What should guide every step of this algorithm?

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead