Z-Function vs KMP Failure Function in String Problems
Z-function works forward, KMP looks back—pick the one that matches your problem's natural direction.
Rohan Fontaine
Section
1 story in String Algorithms.
Z-function works forward, KMP looks back—pick the one that matches your problem's natural direction.