Hi Guys, Can you please help me out on this.
I want to generate random numbers with no duplicates (including negative numbers) lets say from -20 til 20 in no particular order. And then I want to find the series of consectuive numbers within the randomly generated numbers that gives the maximum sum of values, locate the beginning of the series and the length of the series (number of values summed to get the maximum number).
For Example (-1, 2, -3, 3, 5)
- Sum = 8 (Sum of 3 and 5) we exclude 2 since it is not part of the consecutive numbers within the series because of -3 in the middle.
- Beginning location of the series = 4 (since 3 is the 4th number within the series).
- Length of the series within the series = 2 (Since 3 and 5 are the two consecutive integers within this series that would give the maximum sum of values).
I need the sum, beggining and the length of the series to be found through formuleas in excel if possible.
I have across a solution in the below link, but can someone do this using formulaes. I believe its called the kadane's algorithm.
http://www.i-programmer.info/program...y-problem.html
Bookmarks