Z-Algorithm

Computes for every position the longest match with the string's own prefix (Z-array) in O(n), finding all pattern occurrences.

Advancedstring matchingZ-arrayprefix matchinglinear
Loading visualization…