其他分享
首页 > 其他分享> > 最大子序列

最大子序列

作者:互联网

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,

Maximum subarray

Maximum subarray

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)

标签:最大,sum,numbers,largest,序列,subarray,array,contiguous
来源: https://www.cnblogs.com/Archer-Fang/p/10558046.html