Iterative DP Solution using c++
\nclass Solution {\npublic:        \n    int f(int n, vector<int> rollMax) {\n        int dp[5001][7];\n        for(int i=0;i<=6;i++) dp[0][i] = 1;\n        \n 
```\nclass Solution {\npublic:        \n    int f(int n, vector<int> rollMax) {\n        int dp[5001][7];\n        for(int i=0;i<=6;i++) dp[0][i] = 1;\n        \n        for(int i=1;i<=n;i++) {\n            for(int j=0;j<=6;j++) {\n                int ret = 0;\n                \n                for(int k=1;k<=6;k++) {\n                    if(j == k) continue;\n                    \n                    for(int l=1;l<=rollMax[k-1] && i-l >= 0;l++) {\n                        ret = (ret + dp[i-l][k]) % 1000000007;\n                    }\n                }\n                \n                dp[i][j] = ret;\n            }\n        }\n        \n        return dp[n][0];\n    }\n    \n    int dieSimulator(int n, vector<int>& rollMax) {\n        return f(n, rollMax);\n    }\n};\n```
[]