simple easy to understand c++ solution
class Solution {\npublic:\n    int numPermsDISequence(string s) {\n        constexpr int mod=1\'000\'000\'007;\n        int n=s.length();\n        vector>DP(n+1
class Solution {\npublic:\n    int numPermsDISequence(string s) {\n        constexpr int mod=1\'000\'000\'007;\n        int n=s.length();\n        vector<vector<int>>DP(n+1, vector<int>(n+1));\n        for(int i=0;i<=n;++i){\n            DP[0][i]=1;\n        }\n        for(int i=1;i<=n;++i){\n            if(s[i-1]==\'I\'){\n                int postsum=0;\n                for(int j=n-i;j>=0;--j){\n                    postsum=(postsum+DP[i-1][j+1])%mod;\n                    DP[i][j]=postsum;\n                }\n            }else{\n                int presum=0;\n                for(int j=0;j<=n-i;++j){\n                    presum=(presum+DP[i-1][j])%mod;\n                    DP[i][j]=presum;\n                }\n            }\n        }\n        return DP[n][0];\n    }\n};
[]