C# Solution
\n//This is based on a couple others..\n//I take no credit other than the obvious refactoring.\n//I deliberately chose the one that seemed easier to understand,
```\n//This is based on a couple others..\n//I take no credit other than the obvious refactoring.\n//I deliberately chose the one that seemed easier to understand, not the fastest.\n\npublic class Solution \n{\n    //Number of Permutations Table - Using long to avoid a lot of mod operations.\n    long [,] np;\n    int MOD;\n    \n    public void GetNumPermutationsEndingIn(int len, int end, int endStart, int endStop)\n    {\n        for(int k = endStart; k <= endStop; k++)\n        {\n            np[len,end] += np[len-1,k];\n        }\n        //This is just trying to keep the value from overflowing..\n        if (np[len,end] > 0xFFFFFFFFFFFF)\n        {\n            np[len,end] = np[len,end]%this.MOD;\n        }\n    }\n    \n    public int NumPermsDISequence(string S) {\n        int n = S.Length;\n        this.MOD = 1000000000 + 7;\n        this.np = new long[n+1,n+1];\n        this.np[0,0] = 1;\n        for(int len = 1; len <= n; len++)\n        {\n            for(int end = 0; end <= len; end++)\n            {\n                if(S[len-1] == \'D\')\n                {\n                    //Here the transformation is to decrease.  This means the previous MUST be bigger than this one.\n                    //The starting point is apparently end not end-1 here to also include the number of permutations frm the previous as a starting point. \n                    //The next np[len,end] is np[len-1,end] + np[len-1,end+1]... + np[len-1,len-1]\n                    GetNumPermutationsEndingIn(len,end,  end/*prev end start*/, len-1/*prev end stop*/);\n                }\n                else\n                {\n                    //The next np[len,end] is np[len-1,0] + np[len-1,1]... + np[len-1,end-1]\n                    GetNumPermutationsEndingIn(len,end,  0/*prev end start*/  , end-1/*prev end stop*/);\n                }\n            }\n        }\n        \n        //To get the complete the complete set a simple sum is required.\n        long res = 0;\n        for(int i = 0; i <= n; i++)\n        {\n            res += np[n,i];\n        }\n        return (int)(res%MOD);\n    }\n}\n```
[]