C++ O(N) Concise
\n\n# define ll long long\nclass Solution {\npublic:\n    int N=1000000007;\n    int dieSimulator(int n, vector<int>& roll) {\n        ll int dp[n][6];\nll int 
```\n\n# define ll long long\nclass Solution {\npublic:\n    int N=1000000007;\n    int dieSimulator(int n, vector<int>& roll) {\n        ll int dp[n][6];\nll int pre[n][6];\nmemset(dp,0,sizeof(dp));\nmemset(pre,0,sizeof(pre));\nfor(int i=0;i<6;i++)\n{    \ndp[0][i]=1;\npre[0][i]=1;\n}\n\nfor(int i=1;i<n;i++)\n{\n for(int j=0;j<6;j++)\n {\n     ll int sum1=0,sum2=0;\n    for(int k=0;k<6;k++)\n    {\n       if(k==j)continue;\n       sum1+=pre[i-1][k];\n        sum1%=N;\n       if(i-roll[j]-1>=0)\n       {sum2+=pre[i-1-roll[j]][k];\n       sum2%=N;\n       }\n    }\n    if(i-roll[j]<0)sum1+=1;\n   dp[i][j]=(sum1-sum2+N)%N;\n    pre[i][j]=(pre[i-1][j]+dp[i][j])%N;\n }\n}\n    \n int ans=0;\nfor(int i=0;i<6;i++)\n{ans+=dp[n-1][i];\nans%=N; \n}\nreturn ans;\n    }\n};\n```
[]