数组中x个连续元素的最小总和(minimum sum of x contiguous elements in an array)
我知道线性时间算法来解决这个问题,你将下一个元素添加到当前总和中的最后一个元素。 我想知道是否有更快的方法来解决这个问题。
I know the linear time algorithm to solve this problem, where you add the next element to, and the last element from the current sum. I'd like to know if there's a faster method to solve this problem.
最满意答案
我们以带有负数的数组作为数组。 要解决您的问题,您应该添加所有这些。 因此,这个问题的复杂性下限是O(n)。
Let's take e.g. array with negative numbers. To solve your problem you should add all of them. So lower limit of complexity of this problem is O(n).
更多推荐
发布评论