1223. Dice Roll Simulation Using Dynamic Programming Programming with memoization
\nclass Solution {\n    vector<vector<vector<int>>> dp;\n    int mod=(int)(1e9+7);\npublic:\n    int help(int n,int prev,int len,vector<int> &r)\n    {\n       
```\nclass Solution {\n    vector<vector<vector<int>>> dp;\n    int mod=(int)(1e9+7);\npublic:\n    int help(int n,int prev,int len,vector<int> &r)\n    {\n        if(n==0)    return 1;\n        int& ans=dp[n][prev][len];\n        if(ans!=-1) return ans;\n        ans=0;\n        for(int i=1;i<=6;i++)\n        {\n            if(i==prev&&len==r[i-1])    continue;\n\t\t\t/* If i==prev so the number is repeat so we have to\n            increase the len to len+1 otherwise we will set it to 1 because\n            we take the i th number which is not our previous number*/\n            ans=(ans%mod+help(n-1,i,(prev==i?len+1:1),r)%mod)%mod;\n        }\n        return ans;\n    }\n    int dieSimulator(int n, vector<int>& rollMax) {\n        \n        dp.resize(n+1,vector<vector<int>>(7,vector<int>(16,-1)));\n        return help(n,0,0,rollMax);\n    }\n};\n```
['Dynamic Programming', 'Recursion', 'Memoization']