## Array Sum Challenge
In this challenge, given an array of integers, the goal is to efficiently
find
the subarray that has the greatest value when
all
of its elements are summed together. Note that because some elements of the
array may be negative, the problem is not solved by simply picking the
start
and end elements of the array to be the subarrray, and summing the entire
array.
{1, 2, -5, 4, -3, 2}The maximum sum of a subarray is 4. It is possible for the subarray to be zero elements in length (if every element of the array were negative). Before you write the code, take some time to think of the most efficient solution possible; it may surprise you. The major goal of this challenge is to test your algorithmic skills rather than merely your ability to write code quickly. View Solution If you like this problem, you may like the book from which I originally learned of the problem, Programming Pearls by Jon Bentley. |