Mental Model
KMP finds a pattern in text by remembering where to restart after a mismatch, avoiding repeated checks.
Analogy: Like reading a book and marking where a sentence starts so if you lose your place, you jump back to the last known start instead of rereading everything.
Text: A B A B A B C A B A B D Pattern: A B A B D Prefix table: [0,0,1,2,0]
