Groups
The Z-function of a string S computes for each position i the length of the longest substring starting at i that matches the prefix of S.
The KMP algorithm finds all occurrences of a pattern in a text in O(n + m) time by never re-checking characters that are already known to match or mismatch.