Suppose I have an array A. I have a series of index pairs (a1, b1), (a2, b2) ... (an, bn)
I want to obtain all the sums of the elements between those pairs. i.e.
sum(A[a1:b1]), sum(A[a2:b2]), sum(A[a3:b3]) ...
In terms of run-time, what's the most efficient way of doing this?
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…