2
public int maximumScore(int[] nums, int[] multipliers) {3
int n = nums.length, m = multipliers.length;4
return helper(nums, multipliers, 0, 0, n - 1, new Integer[m][m]);7
public int helper(int[] nums, int[] multipliers, int idx, int left, int right, Integer[][] memo) {8
if (idx == multipliers.length) return 0;9
if (memo[idx][left] != null) return memo[idx][left];12
nums[left] * multipliers[idx] + helper(nums, multipliers, idx + 1, left + 1, right, memo);15
nums[right] * multipliers[idx] + helper(nums, multipliers, idx + 1, left, right - 1, memo);17
return memo[idx][left] = Math.max(takeLeft, takeRight);