[python] dp O(6*2*n) 100%(50~60ms)
\nfrom collections import deque\nclass Solution(object):\n    def dieSimulator(self, n, rollMax):\n        a,b,m=[deque([0]*x) for x in rollMax],[1]*6,100000000
```\nfrom collections import deque\nclass Solution(object):\n    def dieSimulator(self, n, rollMax):\n        a,b,m=[deque([0]*x) for x in rollMax],[1]*6,1000000007\n        for x in a: x[-1]=1\n        for _ in range(n-1):\n            s=sum(b)%m\n            for i,x in enumerate(a):\n                x.append(s-b[i])\n                b[i]=(s-x.popleft())%m\n        return sum(b)%m\n```\nAn optimized version of O(sum(rollMax) * n) dp.\n\na[i][-j] is the number of sequences ended with j consecutive times i\nb[i] is the sum of a[i]
[]