DP | Recursion + Memoization | Python
Top-Down DP Recursive with memoization (lru_cache):\n\n\t  def dieSimulator(self, n: int, rollMax: List[int]) -> int:\n\t\n\t\t\t@lru_cache(None)\n\t\t\tdef dp(
* Top-Down DP Recursive with memoization (lru_cache):\n\n\t  def dieSimulator(self, n: int, rollMax: List[int]) -> int:\n\t\n\t\t\t@lru_cache(None)\n\t\t\tdef dp(n, last, curlen):\n\t\t\t\tif n == 0:    return 1\n\n\t\t\t\tways = 0\n\t\t\t\tfor i in range(6):\n\t\t\t\t\tif i == last and curlen >= rollMax[i]: continue\n\t\t\t\t\tways += dp(n-1, i, curlen+1 if i==last else 1)\n\t\t\t\treturn ways                \n\n\t\t\treturn dp(n, -1, 0) % int(1e9 + 7)\n    \n       \n\t\t#n = die number\n\t\t#last = last rolled number (1-6)\n\t\t#curlen = length of same number if being passed to subseqnt calls else 0
['Dynamic Programming', 'Recursion', 'Memoization', 'Python']