[Python] DP solution
dp[i][k] means after several rolls,\nthe number of sequence that ends with k times i.\n\nPython:\npython\n    def dieSimulator(self, n, rollMax):\n        mod =
`dp[i][k]` means after several rolls,\nthe number of sequence that ends with `k` times `i`.\n\n**Python:**\n```python\n    def dieSimulator(self, n, rollMax):\n        mod = 10**9 + 7\n        dp = [[0, 1] + [0] * 15 for i in xrange(6)]\n        for _ in xrange(n - 1):\n            dp2 = [[0] * 17 for i in xrange(6)]\n            for i in xrange(6):\n                for k in xrange(1, rollMax[i] + 1):\n                    for j in xrange(6):\n                        if i == j:\n                            if k < rollMax[i]:\n                                dp2[j][k + 1] += dp[i][k] % mod\n                        else:\n                            dp2[j][1] += dp[i][k] % mod\n            dp = dp2\n        return sum(sum(row) for row in dp) % mod\n```\n
[]