首页 > 代码库 > [LintCode] Maximum Subarray 最大子数组

[LintCode] Maximum Subarray 最大子数组

 

Given an array of integers, find a contiguous subarray which has the largest sum.

 Notice

The subarray should contain at least one number.

Have you met this question in a real interview? 
Yes
Example

Given the array [−2,2,−3,4,−1,2,1,−5,3], the contiguous subarray [4,−1,2,1] has the largest sum = 6.

Challenge 

Can you do it in time complexity O(n)?

 

s

 

[LintCode] Maximum Subarray 最大子数组