Count the Number of Inversions
Build permutations one position at a time, tracking how many inversions each prefix has and zeroing counts that break a requirement.
Build permutations one position at a time, tracking how many inversions each prefix has and zeroing counts that break a requirement.