When A Means Zero
A candidate writes the character mapping as c - 'a' instead of c - 'a' + 1:
hash_value = (hash_value + (c - 'a') * p_pow) % m; // a -> 0, b -> 1, ...
with p = 31, m = 1e9 + 9, and the exponent growing with the index. Which pair of distinct strings does this version give the same hash?
Sign in to answer questions and track your progress
Sign In