KMP Prefix Function
Find a pattern in O(n + m).
The Pattern-Matching Problem
You want to find where a small pattern appears inside a big text. Naive checks are slow, so contests reward a smarter scan. 🔍
Why Naive Search Hurts
Comparing the pattern at every position can cost O(n*m) time. On large inputs that quietly blows your time limit.