dsa10 min read
Polynomial String Hashing — O(1) Substring Comparison with Prefix Hashes
Precompute polynomial prefix hashes once in O(n) and answer substring equality queries in O(1) for the lifetime of the string. The Swiss army knife behind longest duplicate substring, longest common substring binary search, and dozens of competitive programming techniques.
Read →