Rolling Hash and the Rabin-Karp Algorithm
Turn a whole substring into one number, update that number in O(1) as the window slides, and compare numbers instead of characters.
9 min readUpdated 2026-09-03stringsrolling-hashrabin-karp
Turn a whole substring into one number, update that number in O(1) as the window slides, and compare numbers instead of characters.