~/boss / fifth-strongest
Quickselect
The 5th Strongest
Find the 5th strongest monster without sorting anyone. Every round, throw one side away.
Loading the fight…
How to beat it
Crown a pivot: weaker monsters go left, stronger go right. Count the stronger side. If the one you want is in there, forget everyone else; if exactly 4 are stronger, the pivot is the 5th; otherwise search the weaker side for what's left. Every round, part of the army is thrown away unsorted.
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/kth-largest-element-in-an-array there. Sign in with your email to keep your progress on every device.