Monday, July 6, 2015

Leetcode Question No. 53: Maximum subarray sum

July 6, 2015

problem statement:

Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
For example, given the array [−2,1,−3,4,−1,2,1,−5,4],
the contiguous subarray [4,−1,2,1] has the largest sum = 6.


Study the code:
http://joycelearning.blogspot.ca/2013/10/leetcode-maximum-subarray.html

1. Keyword lookup: 

DP problem: Kadane's algorithm, maximum subarray sum


2. Write a program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.



No comments:

Post a Comment