String Hashing
We need a hash function to convert a string into an integer, called the hash of that string. The following condition has to hold: For two strings and ,
but reverse is not guaranteed. We only hope that
Polynomial Rolling Hash Function
Section titled “Polynomial Rolling Hash Function”where and and are some chosen, positive numbers.
// Precomputing the powers of p might give a performance boost.