Leetcode 903. Valid Permutations for DI Sequence
Count the number of permutations of 0..n that satisfy the adjacent inequality pattern given by s (s[i] = 'I' means perm[i] < perm[i+1], 'D' means perm[i] > perm[i+1]) and return the result modulo 10^9+7. The core challenge is to efficiently enumerate/count these permutations (n ≤ 200) using dynamic programming / combinatorial range-sum transitions that exploit runs of consecutive I's or D's.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.