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

Sign in to watch this lesson
Algorithms - Strings · 4:38
Rabin-Karp finds a pattern by sliding a window along the text and comparing one number per position: the window's prefix-hash difference against the pattern's hash times p^i, for O(|s| + |t|) in total. We watch a fake hit appear with a toy modulus and get caught by checking the letters, then use binary search on the length, with one hashing sweep per probe, to find the longest repeated substring.