最大子序列

Posted archer-fang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了最大子序列相关的知识,希望对你有一定的参考价值。

Maximum subarray problem

 

The maximum subarray problem is the task of finding the contiguous subarray within a one-dimensional array, a[1...n], of numbers which has the largest sum, where,

技术图片

技术图片

Example

The list usually contains both positive and negative numbers along with 0. For example, for the array of values −2, 1, −3, 4, −1, 2, 1, −5, 4 the contiguous subarray with the largest sum is 4, −1, 2, 1, with sum 6.

代码如下:

技术图片

时间复杂度O(n)

以上是关于最大子序列的主要内容,如果未能解决你的问题,请参考以下文章

动态规划求最大子序列之和以及序列号

找到总和最大的递增子序列

最大连续子序列问题(tyvj1305)

子序列最大和

dp-最大连续子序列的和

求连续序列的最大子序列和