数组中x个连续元素的最小总和(minimum sum of x contiguous elements in an array)

编程入门 行业动态 更新时间:2024-10-10 21:21:40
数组中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).

更多推荐

本文发布于:2023-07-15 07:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1111424.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:总和   组中   最小   元素   minimum

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!