首页 > 其他 > 详细

最大子序列

时间:2019-03-19 13:39:36      阅读:136      评论:0      收藏:0      [点我收藏+]

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)

最大子序列

原文:https://www.cnblogs.com/Archer-Fang/p/10558046.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!