Given as input, a sorted array of floats, I need to find the total number of pairs (i,j)
such as A[i]*A[j]>=A[i]+A[j]
for each i < j
.
I already know the naive solution, using a loop inside other loop, which will give me O(n^2) algorithm, but i was wondering if there is a more optimal solution.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…