Python3 bottom-up DP with comments -  Dice Roll Simulation
\nclass Solution:\n    def dieSimulator(self, n: int, rollMax: List[int]) -> int:\n        MOD = 1_000_000_007\n        \n        # dp[i][j] represents answer f
```\nclass Solution:\n    def dieSimulator(self, n: int, rollMax: List[int]) -> int:\n        MOD = 1_000_000_007\n        \n        # dp[i][j] represents answer for rolling i times and the last face is j.\n        dp = [[0 for _ in range(6)] for i in range(n+1)]\n        \n        for j in range(6):\n            dp[1][j] = 1\n            \n        for i in range(2, n+1):\n            for j in range(6):\n                k = i - rollMax[j]\n                dp[i][j] = sum(dp[i-1]) % MOD\n                # Eliminate results that have rollMax[j] trailing j\'s. \n                if k == 1:\n                    dp[i][j] -= 1\n                elif k > 1:\n                    dp[i][j] -= sum(dp[k-1]) % MOD - dp[k-1][j]\n                    \n        return sum(dp[-1]) % MOD\n```
['Dynamic Programming', 'Python', 'Python3']