Pregunta de entrevista de Bjak

Was asked a string manipulation problem,