dsa2 min read
String Hashing — Polynomial Hash for O(1) Substring Comparison
Precompute polynomial prefix hashes to compare any two substrings in O(1). Enables O(n log n) LCP computation and O(n) duplicate detection.
Read →
webcoderspeed.com
2 articles
Precompute polynomial prefix hashes to compare any two substrings in O(1). Enables O(n log n) LCP computation and O(n) duplicate detection.
Build a suffix array in O(n log²n) using doubling sort. Enables O(m log n) substring search, longest common substring, and number of distinct substrings.