~/boss / dragon-cave

Dijkstra's algorithm (shortest paths with a heap)

The Dragon's Cave

Fire always takes the cheapest tunnel. Settle the caves in its order and reach the dragon.

Loading the fight…

How to beat it

Every cave keeps the cheapest fire found so far into it; the entrance starts at 0. Settle the unsettled cave with the smallest number: with no negative tunnels, nothing cheaper can ever reach it. Then try its tunnels: if its number plus a tunnel beats a neighbour's number, lower it. Stop when the dragon's lair settles.

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/network-delay-time there. Sign in with your email to keep your progress on every device.

More bosses

esc