~/boss / castle-roads
Kruskal's algorithm (minimum spanning tree)
The Road Builder
Join every castle for the least stone. Cheapest road first, never a loop.
Loading the fight…
How to beat it
Take the roads cheapest first. Castles of one colour already share a king, so a road between them would only close a loop: skip it. Different kings at the two ends? Build it, and their kingdoms join. Stop when you've built one road fewer than there are castles.
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/easy-mst there. Sign in with your email to keep your progress on every device.