Pergunta de entrevista da empresa Paintzen

Algorithm problem involving string matching