z of the same length as the input string s, with all elements set to 0.l and r to 0. These will represent the left and right boundaries of the window of the last known prefix.i is within the window defined by l and r, set z[i] to the minimum of z[i-l] and r-i+1.
b. While the substring starting at i+z[i] matches the prefix of s, increment z[i].
c. If i+z[i]-1 is greater than r, update l to i and r to i+z[i]-1.z array and add the length of s to get the final score.