~/boss / attack-waves
Merge intervals
The Waves
The boss's attacks overlap. Sort them, then merge them into as few waves as you can.
Loading the fight…
How to beat it
Sort the attacks by start time. Walk them in order, keeping one current wave. Starts before the wave ends, or right as it ends? They overlap: stretch the wave's end to the later of the two. Starts after it ends? Close the wave and start a new one.
Now the real boss
Interviews ask for the code. Watch it run, then write it yourself, tested in Python, C++ or Java.
On your phone? Writing code is easier on a laptop: open bossfight.dev/problems/merge-intervals there. Sign in with your email to keep your progress on every device.