js solution dp
\nvar numPermsDISequence = function(s) {\n    let mod = 10**9+7,res = 0\n    const dp = new Array(s.length+1).fill().map(()=>new Array)\n    dp[0][0]=1\n    for
```\nvar numPermsDISequence = function(s) {\n    let mod = 10**9+7,res = 0\n    const dp = new Array(s.length+1).fill().map(()=>new Array)\n    dp[0][0]=1\n    for(i=1;i<s.length+1;i++) {\n        if(s[i-1]===\'D\') {\n            dp[i][i]=0\n            for(j=i-1;j>=0;j--) {\n                dp[i][j]=(dp[i][j+1]+dp[i-1][j])%mod\n            }\n        } else {\n            dp[i][0]=0\n            for(j=1;j<=i;j++) {\n                dp[i][j]=(dp[i][j-1]+dp[i-1][j-1])%mod\n            }\n        }\n    }\n    dp[s.length].map((e)=>{res+=e%mod})\n    return res%mod\n};\n```
['JavaScript']