Pregunta de entrevista de Two Sigma

Question dealing with permutations