LinkedIn | Onsite | Find the kth maximum product
4041

Given two unsorted arrays A1 and A2 containing negative and positive integers of different lengths, find the kth maximum product of A1[i] * A2[j] ( a number from A1 * number from A2)

Example: A1=[7,-20,3,0,10,-70] A2=[0,1,-12, 100, -30] k=3

1st max = -70 * -30 = 2100
2nd max = 100 * 10 = 1000
k = 3rd max = -70 * -12 = 840 ( answer)

Comments (6)