Subarray with largest sum - Java
Came across an interesting puzzle and realized that the mind is getting too used to not thinking..need to exercise the brain more often. Anyways, the puzzle is
Given an array containing both positive and negative integers, find the subarray with the largest sum.
BTW, any guesses for the maximum number of subarrays possible for an array of length n? For some reason, took me a long time to figure this out, write to me if you also go through the same, but better still, try to solve it yourself to clear the dust off the mind cells, I am not sure how much I have been able to shake off, but it is worth a try)
Given an array containing both positive and negative integers, find the subarray with the largest sum.
BTW, any guesses for the maximum number of subarrays possible for an array of length n? For some reason, took me a long time to figure this out, write to me if you also go through the same, but better still, try to solve it yourself to clear the dust off the mind cells, I am not sure how much I have been able to shake off, but it is worth a try)