Polynomial String Hashing
Compare substrings in constant time.
Comparing Substrings Fast
You often need to ask if two substrings are equal. Character-by-character checks are slow, so we turn each string into a number. 🔢
The Hashing Idea
A hash maps a string to a single integer. If two strings differ, their hashes almost always differ too.
All lessons in this course
- KMP Prefix Function
- Polynomial String Hashing
- Z-Function for Pattern Search
- Tries for Prefix Lookups