Multiplying and Adding Rows of 2D and 1D Arrays

You are given a two dimensional array containing arrays of integers and a one dimensional array of integers as arguments. Return the largest sum that can be obtained by multiplying each element of one row of the 2D array by each corresponding element of the 1D array and adding them all together.

The 2D array will always have the same number of columns as there are elements in the 1D array.

Requirements

  • Must return an integer

Example #1

solve([
  [1, 1, 1],
  [-10, -2, 1000],
  [-60, -50, -60]
],[-10, 30, -30])
> 900
  1. Start with the first row of the 2D array: (1 \ -10) + (1 \* 30) + (-30 \* 1) = -10*
  2. Then try the second row: (-10 \ -10) + (-2 \* 30) + (-30 \* 1000) = -29,000*
  3. Then finally the third row: (-60 \ -10) + (-50 \* 30) + (-30 \* -60) = 900*
  4. Since the third row produced the largest integer, we return 900.