~/boss / cursed-word

Rabin-Karp (rolling hash)

The Cursed Book

Roll the hash across the book. Find every cursed word, and don't fall for the fakes.

Loading the fight…

How to beat it

Every letter is worth a number, and a chunk of the book hashes to one number. Slide one letter: drop the letter that left, add the one that came in. Only read the letters when the hash matches the cursed word's: same hash, different letters is a spurious hit.

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/string-hashing-find-all there. Sign in with your email to keep your progress on every device.

More bosses

esc