String Functions
We consider a string of n characters, indexed 1,2,\dots,n. Your task is to calculate all values of the following functions: - z(i) denotes the maximum length of a substring that begins at position i and is a prefix of the string. In addition, z(1)=0. - \pi(i) denotes the maximum length of a substring that ends at position i, is a prefix of the string, and whose length is at most i-1. Note that
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start