Prefix function. Knuth-Morris-Pratt algorithm - Course 5