Compute the Z-Array
For a string s, z[i] is the length of the longest common prefix of s and the suffix starting at i, with z[0] defined as the length of s. Print the Z-array in O(n).
Constraints
1 <= |s| <= 10^5 Lowercase letters
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.