3290. Maximum Multiplication Score Medium
1/**
2 * [3290] Maximum Multiplication Score
3 *
4 * You are given an integer array a of size 4 and another integer array b of size at least 4.
5 * You need to choose 4 indices i0, i1, i2, and i3 from the array b such that i0 < i1 < i2 < i3. Your score will be equal to the value a[0] * b[i0] + a[1] * b[i1] + a[2] * b[i2] + a[3] * b[i3].
6 * Return the maximum score you can achieve.
7 *
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">a = [3,2,5,6], b = [2,-6,4,-5,-3,2,-7]</span>
11 * Output: <span class="example-io">26</span>
12 * Explanation:<br />
13 * We can choose the indices 0, 1, 2, and 5. The score will be 3 * 2 + 2 * (-6) + 5 * 4 + 6 * 2 = 26.
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">a = [-1,4,5,-2], b = [-5,-1,-3,-2,-4]</span>
18 * Output: <span class="example-io">-1</span>
19 * Explanation:<br />
20 * We can choose the indices 0, 1, 3, and 4. The score will be (-1) * (-5) + 4 * (-1) + 5 * (-2) + (-2) * (-4) = -1.
21 * </div>
22 *
23 * Constraints:
24 *
25 * a.length == 4
26 * 4 <= b.length <= 10^5
27 * -10^5 <= a[i], b[i] <= 10^5
28 *
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/maximum-multiplication-score/
33// discuss: https://leetcode.com/problems/maximum-multiplication-score/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38 pub fn max_score(a: Vec<i32>, b: Vec<i32>) -> i64 {
39
40 }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn test_3290() {
51 }
52}
53
Back
© 2025 bowen.ge All Rights Reserved.