Prefix function. Knuth-Morris-Pratt algorithm
Prefix function. Knuth-Morris-Pratt algorithm
Definition
Given a string of length .
The prefix function of the string for position is the length of the longest proper prefix of the substring that is also its suffix.