Z-function
Z-function
Introduction
Note. This article uses -based indices, i.e., the first character of the string has index , and the last has .
The Z-function of a string at position is the length of the longest prefix of the substring starting at position that matches the prefix of the entire string .
