Data Structures:
z_algorithm()
Math:
Graphs:
Z algorithm Reference: D. Gusfield, Algorithms on Strings, Trees, and Sequences: Computer Science and Computational Biology