Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    3290 - Maximum Multiplication Score\.

    Medium

    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 <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array b such that <code>i<sub>0</sub>< i<sub>1</sub>< i<sub>2</sub>< i<sub>3</sub></code>. Your score will be equal to the value <code>a0 * bi<sub>0</sub> + a1 * bi<sub>1</sub> + a2 * bi<sub>2</sub> + a3 * bi<sub>3</sub></code>.

    Return the maximum score you can achieve.

    Example 1:

    Input: a = 3,2,5,6, b = 2,-6,4,-5,-3,2,-7

    Output: 26

    Explanation: We can choose the indices 0, 1, 2, and 5. The score will be 3 * 2 + 2 * (-6) + 5 * 4 + 6 * 2 = 26.

    Example 2:

    Input: a = -1,4,5,-2, b = -5,-1,-3,-2,-4

    Output: \-1

    Explanation: We can choose the indices 0, 1, 3, and 4. The score will be (-1) * (-5) + 4 * (-1) + 5 * (-2) + (-2) * (-4) = -1.

    Constraints:

    • a.length == 4

    • <code>4 <= b.length <= 10<sup>5</sup></code>

    • <code>-10<sup>5</sup><= ai, bi<= 10<sup>5</sup></code>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Long maxScore(IntArray a, IntArray b)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait