Java Solution !!!
\n    public int numPermsDISequence(String S) {\n        int len = S.length(), N = len + 1, mod = 1000000007;\n        int[][] dp = new int[N+1][N];\n        \n
```\n    public int numPermsDISequence(String S) {\n        int len = S.length(), N = len + 1, mod = 1000000007;\n        int[][] dp = new int[N+1][N];\n        \n        for(int i = 0; i < N; i++) dp[1][i] = 1;\n        \n        for(int i = 1; i <= len; i++) {\n            if(S.charAt(i-1) == \'D\') for(int j = N - i -1; j >= 0; j--) dp[i+1][j] = (dp[i+1][j+1] + dp[i][j+1])%mod;\n            else  for(int j = 0; j <= N - i-1; j++) dp[i+1][j] = ((j > 0 ? dp[i+1][j-1] : 0) + dp[i][j])%mod;\n        }\n        \n        return dp[N][0];\n    }\n```
[]