Count permutations with exactly n inversions | Turing Interview Question