algorithm - Find the maximum interval sum in a list of real numbers -


There are questions of an interview that an associate asked for the programming status. I thought the interviewer was very good to see this.

Looking at a list of real numbers N, say that [a_1, a_2, ..., a_N]

code>, maximum value What is the complexity of finding M, for which index 1 & lt; = I & lt; = J & lt; = N is such that

a_i + a_ {i + 1} + ... + a_j = m ?

If this is the classic CS problem then apologize to me.

complexity is:

algorithm (MaxSume, MaxStart Index, maxand index) . It collects a partial sum in currentMaxSum and when it grows larger than the partial amount of maxSum , then updates the optimal category.

Comments