Practice Discrete Math

Z Function

Browse Z Function lessons inside Algorithmic Thinking and Complexity.

1 lessons · 5 questions

Algorithmic Thinking and Complexity

Big-O, loop analysis, graph algorithms, invariants, and developer-focused discrete math.

1 lessons · 410 questions

Z Function

1 lessons · 5 questions

Least You Need to Know: Z-Function, Prefix Matches, and Pattern Search by Concatenation
The Z-function at position i stores the length of the longest substring starting at i that matches the whole string prefix. This lets you reason about repeated prefix structure and perform pattern search via concatenation.
Open lesson