Constructs a Z-array representing the longest substring starting from each position that matches the prefix, enabling efficient pattern search.
Explain code with DocComment! Try out your own code!