Maximum Multiplication Score - Problem
You are given an integer array a of size 4 and another integer array b of size at least 4.
You need to choose 4 indices i₀, i₁, i₂, i₃ from array b such that i₀ < i₁ < i₂ < i₃.
Your score will be equal to a[0] * b[i₀] + a[1] * b[i₁] + a[2] * b[i₂] + a[3] * b[i₃].
Return the maximum score you can achieve.
Input & Output
Example 1 — Basic Case
$
Input:
a = [3,2,-1,1], b = [5,-3,4,2,-1,6]
›
Output:
26
💡 Note:
Choose indices [0,3,4,5]: 3×5 + 2×2 + (-1)×(-1) + 1×6 = 15 + 4 + 1 + 6 = 26
Example 2 — Negative Values
$
Input:
a = [-1,4,5,2], b = [2,1,8,3,6]
›
Output:
68
💡 Note:
Choose indices [1,2,3,4]: (-1)×1 + 4×8 + 5×3 + 2×6 = -1 + 32 + 15 + 12 = 58
Example 3 — Minimum Size
$
Input:
a = [1,2,3,4], b = [5,6,7,8]
›
Output:
70
💡 Note:
Must use all indices [0,1,2,3]: 1×5 + 2×6 + 3×7 + 4×8 = 5 + 12 + 21 + 32 = 70
Constraints
- a.length == 4
- 4 ≤ b.length ≤ 105
- -105 ≤ a[i], b[i] ≤ 105
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code