A rolling hash lets you update the hash of a window when you shift by one character (remove left, add right). Rabin–Karp compares hashes to find candidate matches, then usually verifies the substring to avoid false positives. Caveat: hashes can collide, so without verification it’s not guaranteed correct.