Implementation of Knuth-Morris-Pratter