Skip to content

Commit 0d34beb

Browse files
added a new question
1 parent ca51246 commit 0d34beb

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Minimum-Pairwise-Product.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
Question: Minimum Pairwise Product
3+
4+
You are given an array of N size, and another array of M size.
5+
6+
`Compatibility` of two arrays A and B is measured as:
7+
8+
1. Two arrays are compatible if and only if they have an equal number of elements.
9+
2. `Compatibility` value of arrays A and B each having length L = A1*B1 + A2*B2 + … + AL*BL.
10+
11+
You can remove any number of element from both of these arrays to get an `compatibility`.
12+
13+
Print the maximum possible `compatibility`.
14+
15+
Input Format
16+
First line contains two space separated integers denoting N and M.
17+
Next line contains N space separated integers denoting the elements of array A.
18+
Next line contains M space separated integers denoting the elements of array B.
19+
20+
Output Format
21+
Print the maximum compatibility value it's possible to achieve by removing some elements from both the arrays
22+
23+
Constraints
24+
1<=N,M<=1000
25+
-105<=Ai, Bi<=105
26+
27+
Sample Input 1
28+
3 4
29+
-1 2 1
30+
-100 3 10 -9
31+
32+
Sample Output 1
33+
120
34+
35+
Explanation of Sample 1
36+
Erase the 3rd element of array A. Array A becomes = [-1, 2]
37+
Erase the 2nd and 4th element of array A. Array A becomes = [-100, 10]
38+
Compatibility values of these arrays = [(-1)*(-100) + 2*10] = 120
39+
"""

0 commit comments

Comments
 (0)