0PricingLogin
Competitive Programming Academy · Lesson

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

  1. KMP Prefix Function
  2. Polynomial String Hashing
  3. Z-Function for Pattern Search
  4. Tries for Prefix Lookups
← Back to Competitive Programming Academy