~/boss / median-scales
Two heaps (running median)
The Middle Boss
Monsters keep coming. Keep two heaps level and call the median every time.
Loading the fight…
How to beat it
The weaker half is a max heap, so its top is its strongest. The stronger half is a min heap, so its top is its weakest. Drop each monster on its side; if one heap gets two bigger, move its top across. The median is the top of the bigger heap, or the average of the two tops.
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/find-median-from-data-stream there. Sign in with your email to keep your progress on every device.