Two Sigma Interview Question

Question dealing with permutations