Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
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.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.