[Python3] | Top-Down DP O(N^2)
\nclass Solution:\n    def numPermsDISequence(self, s: str) -> int:\n        n,ans = len(s),0\n        mod = 1_00_00_00_000 + 7\n        memo = [[-1] * 201 for 
```\nclass Solution:\n    def numPermsDISequence(self, s: str) -> int:\n        n,ans = len(s),0\n        mod = 1_00_00_00_000 + 7\n        memo = [[-1] * 201 for i in range(201)]\n        def dp(ind,prevNum):\n            if ind < 0:\n                return 1\n            if memo[ind][prevNum] != -1:\n                return memo[ind][prevNum]\n            val = 0\n            if s[ind] == \'D\':\n                for more in range(prevNum+1,n+1):\n                    if more not in vis:\n                        vis.add(more)\n                        val += dp(ind-1,more)\n                        vis.remove(more)\n            else:\n                for less in range(prevNum):\n                    if less not in vis:\n                        vis.add(less)\n                        val += dp(ind-1,less)\n                        vis.remove(less)\n            memo[ind][prevNum] = val\n            return memo[ind][prevNum]\n        for i in range(n+1):\n            vis = set([i])\n            ans += dp(n-1,i)\n        return ans % mod\n            \n```
['Dynamic Programming', 'Python', 'Python3']