Valid Permutations for DI Sequence
Count permutations by the relative rank of the last element, extending one D or I at a time with prefix sums.
Count permutations by the relative rank of the last element, extending one D or I at a time with prefix sums.