Knuth-Morris-Pratt search (KMP)