Pergunta de entrevista da empresa Two Sigma

Question dealing with permutations