Description
Given arrays nums and multipliers, perform m operations: multiply nums end with multiplier, add to score, remove from nums. Maximize score. Return the result as an integer.
Examples
Input:
nums = [1,2,3], multipliers = [3,2,1]Output:
14Explanation:
1*3 + 3*2 + 2*1 = 14.
Input:
nums = [1], multipliers = [1]Output:
1Explanation:
Edge case with a single-element array.
Input:
nums = [-5,4,2,-3], multipliers = [2,3]Output:
2Explanation:
The best sequence of picks gives a total score of 2, so the answer is 2.
Constraints
- •
1 ≤ multipliers.length ≤ 1000