LintCode问题图解-26
2017-11-04 本文已影响19人
billliu_0d62
本文准备讲解1个简单的算法编程问题, 这个算法编程问题来自LintCode平台。不了解.LintCode平台的读者可以阅读笔者文章(在线编程平台推荐-LeetCode)。问题的英文版本描述如下:
Maximum Subarray
Given an array of integers, find a continuous subarray which has the largest sum.
Example
Given the array [−2,2,−3,4,−1,2,1,−5,3], the continuous subarray [4,−1,2,1] has the largest sum =6.
子数组
给定1个整数数组,找到1个具有最大和的子数组,返回子数组的和。
样例
给出数组 [−2,2,−3,4,−1,2,1,−5,3],符合要求的子数组为 [4,−1,2,1],和为6。
这道题目是1个很好的题目,但是没有多种效能接近的算法处理方案。现在公布1种高效简单的算法方案。
高效简单的算法