Pergunta de entrevista da empresa Goldman Sachs

Based on string manipulation and patterns