AlgoMaster Logo

KMP (Knuth-Morris-Pratt) Algorithm

text=aabxaaabxaaab,pattern=aaab
0 / 44
textpatternlps[ ]0123456789101112aabxaaabxaaabaaab012300000123
algomaster.io
Step:KMP Algorithm: First build the LPS (Longest Proper Prefix Suffix) array, then search.