You have two arrays A and B. They have the same length and values are from positive integers. For example:
A = [6, 3, 4, 8, 3] B = [2, 4, 2, 1, 2]
You need to find such two indexes i, j where i != j such that expression A[i] * B[i] + A[i] * B[j] + A[j] * B[j] is maximized. For example here it is i = 3, j = 1 which gives maximum of 52