Here’s my recursive solution, I can’t figure out what’s wrong, please help!!!
class Solution:
def maximumScore(self, nums: List[int], multipliers: List[int]) -> int:
self.seen, self.n, self.m = {}, nums, multipliers
return self.dp(0, len(nums) - 1, 0)
def dp(self, l:int, r: int, i: int, s = 0):
if i == len(self.m): return s
if (l, r, i) in self.seen:
return self.seen[(l, r, i)]
left = self.dp(l + 1, r, i + 1, s + (self.m[i] * self.n[l]))
right = self.dp(l, r - 1, i + 1, s + (self.m[i] * self.n[r]))
self.seen[(l, r, i)] = max(left, right)
return self.seen[(l, r,)]