Pergunta de entrevista da empresa Nielsen

Algorithm involving strings and how to work with it