Pregunta de entrevista de Paintzen

Algorithm problem involving string matching