Mental Model
KMP finds a pattern in text by skipping unnecessary checks using a precomputed table of longest prefix-suffix matches.
Analogy: Imagine searching for a word in a book by remembering parts of the word you already matched, so you don't start over from the beginning each time you find a mismatch.
Text: A B C D A B C D A B C
Pattern: A B C D A B
↑
Prefix Table: [0,0,0,0,1,2]
