Google | Phone (London) | Maximize sum with multiplier array
Anonymous User
3772

I had two problems, the first one was exactly https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards/ so will not open another thread.
The second one as the following :

You are given one more array of size K. This array is called a multiplier array. First element will get multiplied with the first number chosen. Your task is to maximise the sum of the numbers. In short :

A : [2,13,7,15]
B : [2,3]

You can choose :
1- 2 * 2 + 13 * 3 or
2- 2 * 2+ 15 * 3 or
3- 15 * 2 + 2 * 3 or
4- 15 * 2 + 7 * 3

Another example :
A: [-2,8,1,15,-6]
B: [3,2,5]

1: -2 * 3 + 8 * 2 + 1 * 5 or
2: -2 * 3 + -6 * 2 + 15 *5
[...]

(In short you've to choose from Left or Right on the array A the amount of number of elements for B.length which multiplied for elements in A will maximize the sum )

Array A has no constraint (It could filled also with negative numbers)
I gave a bruteforce approach nothing come in my mind (anoyone as some idea?).

After 3 hours recruiter call, and rejected again :(.

Comments (18)