Pergunta de entrevista da empresa Jane Street

Riddle about palindromes and permutations