Z Algorithm
Calculates the length of the longest common prefix of S and S[i:] for all i.
z_algorithm
Arguments
S: str: string to calculate
Returns
list[int]: list of the length of the longest common prefix ofSandS[i:]

Calculates the length of the longest common prefix of S and S[i:] for all i.
S: str: string to calculatelist[int]: list of the length of the longest common prefix of S and S[i:]