~/boss / kingdoms
Union-find
The Eight Kingdoms
Sign every treaty. Find each kingdom's king, and make one bow.
Loading the fight…
How to beat it
Every castle points toward its king. For a treaty, follow both kingdoms' arrows to their kings. Different kings: one bows. Same king: they're already allies.
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/number-of-provinces there. Sign in with GitHub to keep your progress on every device.