C++ O(N) solution
Inutition: Given a target find a number of distinct ways to reach the target.\n\n#define ll long long int\n#define mod 1000000007\nclass Solution {\npublic:\n  
Inutition: Given a target find a number of distinct ways to reach the target.\n```\n#define ll long long int\n#define mod 1000000007\nclass Solution {\npublic:\n    int dieSimulator(int n, vector<int>& rollMax) {\n        int i, j, k, m=rollMax.size(), ans=0;\n        vector<vector<ll>> dp(n+1, vector<ll>(7));\n        for(i=1; i<7; i++){\n            dp[1][i]=1;\n            dp[0][i]=1;\n        }\n        for(int jumps=2; jumps<=n; jumps++){\n            for(i=1; i<7; i++){\n                for(k=1; k<=min(jumps, rollMax[i-1]); k++){\n                    for(j=1; j<7; j++){\n                        if(jumps-k==0){\n                            dp[jumps][i]=(dp[jumps][i]+1)%mod;\n                            break;\n                        }\n                        if(j!=i){\n                            dp[jumps][i]=(dp[jumps][i]+dp[jumps-k][j])%mod;\n                        }\n                    }\n                }\n            }\n        }\n        for(auto elt:dp[n])\n            ans=(ans+elt)%mod;\n        return ans;\n    }\n};\n```
['Dynamic Programming']