Problem 903 · Hard

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.

Open the interactive visualisation