I was asked this algorithm question during my onsite interview. Since I was not asked to sign NDA, I post it here for an answer.
Given an array of REAL
Ignoring negative numbers for the moment...
Let A[i..j] mean A[i]*A[i+1]*...*A[j]
A[i..j]
A[i]*A[i+1]*...*A[j]
The problem is to find max(A[i..j])
max(A[i..j])
Notice that A[i..j] = A[0..j] / A[0..i-1]
A[i..j] = A[0..j] / A[0..i-1]
So if we calculate A[0..x] for all x.
A[0..x]
We can then determine max(A[i..j]) = max(A[0..x]) / min(A[0..y])
max(A[i..j]) = max(A[0..x]) / min(A[0..y])