~/boss / hero-race

Big O: n² vs n log n

The Big O Showdown

Two heroes, one speed. Call each hero's work, then watch who wins at a million.

Loading the fight…

How to beat it

The slow hero checks every pair: n × n, so a million items is a trillion checks. The fast hero splits the items in half again and again: about 20 levels for a million, each touching every item, so 20 million checks. At 10 items it's a tie; at a million one finishes in a blink and the other takes hours.

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

More bosses

esc