C++ | Easy to understand | DP
dp[i][j][k] denotes , ith time, jth face(0-5) and k = jth face k consicutive times.\n\n\n    vector<vector<vector<long long>>> dp;\n    int mod = 1e9+7;\n    lo
dp[i][j][k] denotes , ith time, jth face(0-5) and k = jth face k consicutive times.\n\n```\n    vector<vector<vector<long long>>> dp;\n    int mod = 1e9+7;\n    long long recr(int n,int ele, int times, vector<int> &rollMax)\n    {\n        if(n==0) return 0;\n        if(dp[n][ele][times] != -1) return dp[n][ele][times];\n        long long ans = 0;\n        for(int i = 0;i<6;i++)\n        {\n            if(i == ele)\n            {\n                if(times < rollMax[i]) ans += 1 + recr(n-1,i,times+1,rollMax);\n            }\n            else\n            {\n                ans += 1 + recr(n-1,i,1,rollMax);\n            }\n            ans %= mod;\n        }\n        return dp[n][ele][times] = ans;\n    }\n    int dieSimulator(int n, vector<int>& rollMax) {\n        dp.resize(n+1,vector<vector<long long>>(7,vector<long long>(16,-1)));\n        int ans = (recr(n,6,0,rollMax) - recr(n-1,6,0,rollMax)+mod)%mod;\n        return ans;\n    }\n\n```
['Dynamic Programming', 'C']