Pregunta de entrevista de Blueshift

the question was about string permutation