Skip to content

Files

Failed to load latest commit information.

Latest commit

 Cannot retrieve latest commit at this time.

History

History

053_maximum_subarray

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

On first thought, this appears to be a O(N^2) problem.

But actually, it can be solved in a single pass: maintain a partial sum, when it is positive, add it to element i, else, reset sum from element i (sum = nums[i]).

Time: O(N).