Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 52s1 days 16 hours 1 minutes 52 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 52s1 days 16 hours 1 minutes 52 seconds.

Sign in to watch this lesson
Algorithms - Strings · 5:17
A polynomial rolling hash turns any string into one number, and prefix hashes let us compare two windows of any length with a single integer test. We build the hash of abc and the prefix hashes of abcab, align windows by a power of p instead of a modular inverse, pick the base and modulus, measure the birthday bound (476 colliding pairs among a million strings with one hash, none with two), and watch a Thue-Morse string break every 64-bit overflow hash.