Module 4.15 — KMP and Naive pattern matching
failure[i] = length of longest proper prefix that is also a suffix of pattern[0..i]
When a mismatch occurs at pattern[j], the failure table tells us the longest prefix of pattern[0..j-1] that is also a suffix. We skip to that position instead of restarting from scratch.