revised_backtrack...
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    string s="";\n    int n;\n    int dp[203][203];\n    int m=1e9+7;\n    int solve(int idx,int prev, vector<int>&vis)\n    {\n        if(idx==n) return 1;        \n        if(dp[idx+1][prev+1]!=-1) return dp[idx+1][prev+1];\n        long long ans=0;\n        if(idx==-1)\n        {\n            for(int i=0; i<=n; i++) \n            {\n                vis[i]=1;\n                ans+=solve(0,i,vis)%m;\n                ans%=m;\n                vis[i]=0;\n            }\n        }else\n        {\n            for(int i=0; i<=n; i++)\n            {\n                if(vis[i]==0 )\n                {\n                    if(s[idx]==\'D\' &&i<prev)\n                    {\n                        vis[i]=1;\n                        ans+=solve(idx+1,i, vis)%m;\n                        ans%=m;\n                        vis[i]=0;\n                    }else if(s[idx]==\'I\' && i>prev)\n                    {\n                        vis[i]=1;\n                        ans+=solve(idx+1,i, vis)%m;\n                        ans%=m;\n                        vis[i]=0;\n                    }\n                }\n            }\n        }\n        return dp[idx+1][prev+1]=(int)ans;\n    }\n    \n    int numPermsDISequence(string s1) \n    {\n        s=s1;\n        n=s.size();\n        vector<int> vis(n+1,0);\n        memset(dp,-1,sizeof(dp));\n        return solve(-1,-1,vis);\n    }\n};\n\n```
['Backtracking', 'C++']