• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
April 08, 2024 |630 Views
PROBLEM OF THE DAY : 07/04/2024 | Maximize dot product
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Yash Dwivedi. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of DP but also build up problem-solving skills.

In this problem, we are given, two arrays a and b of positive integers of size n and m where n >= m, the task is to maximize the dot product by inserting zeros in the second array but you cannot disturb the order of elements.

Dot product of array a and b of size n is a[0]*b[0] + a[1]*b[1] + ... + a[n-1]*b[n-1].

Example :

Input: 
n = 5, a[] = {2, 3, 1, 7, 8} 
m = 3, b[] = {3, 6, 7}
Output: 
107
Explanation: 
We get maximum dot product after inserting 0 at first and third positions in second array. Therefore b becomes {0, 3, 0, 6, 7}. 
Maximum dot product = 2*0 + 3*3 + 1*0 + 7*6 + 8*7 = 107.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/optimal-strategy-for-a-game-1587115620/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp14-compiler/2eb5b2fb-1010-49de-b489-0aeef72152db