Prefix function 2026-10-20
For a string , the value is the length of the longest proper prefix of that is also its suffix. Repeatedly following these lengths lists all proper borders of a string; this is the failure-link information used by the Knuth-Morris-Pratt algorithm.