+ 1

c 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. For example, given the 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). i couldn't understand the question... Can anyone help me??

15th Jan 2017, 5:29 AM
Somnath Ghosh
Somnath Ghosh - avatar
1 Answer
+ 1
subarray is: {1} = 1 {1,2} = 2 {1,2,-5} = -2 {2,-5} = -3 {4} = 4 etc... 4 is maximum, so the answer is 4.
24th Apr 2017, 5:06 AM
Yusuf Malikul Mulki
Yusuf Malikul Mulki - avatar