MEMO/C++
\tclass Solution {\n\tpublic:\n    int dp[201][201];\n    int mod=1e9+7;\n    int util(string &s,vector&visited,int curr,int index,int n){\n        if(index==s.
\tclass Solution {\n\tpublic:\n    int dp[201][201];\n    int mod=1e9+7;\n    int util(string &s,vector<int>&visited,int curr,int index,int n){\n        if(index==s.length())\n            return 1;\n        if(dp[curr][index]!=-1)\n            return dp[curr][index];\n        int res=0;\n        visited[curr]=true;\n        if(s[index]==\'I\'){\n            for(int i=curr+1;i<=n;i++)\n                if(!visited[i])\n                res=(res+util(s,visited,i,index+1,n))%mod;\n            \n        }else{\n            for(int i=curr-1;i>=0;i--)\n                if(!visited[i])\n                res=(res+util(s,visited,i,index+1,n))%mod;\n            \n        }\n        visited[curr]=false;\n        return dp[curr][index]=res;\n    }\n    int numPermsDISequence(string s) {\n        memset(dp,-1,sizeof(dp));\n        int n=s.length();\n        vector<int>visited(n+1,false);\n        int res=0;\n        for(int i=0;i<=n;i++)\n         res=(res+util(s,visited,i,0,n))%mod;\n        return res;\n        \n    }\n\t};
['Dynamic Programming']