Pergunta de entrevista da empresa Storm8

Usually the codility test is dynamic programming. But mine was string pattern matching. You have to come up with an optimal(specified time complexity) solution.