Knuth–Morris–Pratt (KMP) Algorithm Interactive Visualizer
The KMP algorithm finds all occurrences of a pattern in a text in guaranteed linear O(n + m) time by precomputing a prefix function (LPS array) so the text pointer never moves backward.
Study Knuth–Morris–Pratt (KMP) Algorithm Explanation · View Multi-Language Code · All Algorithms