Java sol
\nclass Solution {\n    int mod=1000000007;\n    long dp[][];\n    public int numPermsDISequence(String s) {//i: string index   end: end with number end\n      
```\nclass Solution {\n    int mod=1000000007;\n    long dp[][];\n    public int numPermsDISequence(String s) {//i: string index   end: end with number end\n        int len=s.length();\n        long res=0;\n        dp=new long[len+1][len+1];\n        dp[0][0]=1;\n        for(int i=1;i<=s.length();i++){\n            char c=s.charAt(i-1);\n            for(int end=0;end<=i;end++){\n                long val=0;\n                if(c==\'D\'){\n                    for(int j=end;j<=i-1;j++){\n                        val+=dp[i-1][j];\n                        val%=mod;\n                    }\n                }else{\n                    for(int j=0;j<end;j++){\n                        val+=dp[i-1][j];\n                        val%=mod;\n                    }\n                }\n                dp[i][end]=val;\n            }\n        }\n        for(int i=0;i<dp[0].length;i++){\n            res+=dp[len][i];\n            res%=mod;\n        }\n        return (int)(res%mod);\n    }\n}\n```
[]