Printing the max subarray

how can we print the maxSum sub-array too

Try modifying the algorithm yourself. You should be thorough with Kadane’s Algorithm first.

Done.https://ide.codingblocks.com/s/203099

but i am having problem in tracking the start point

Have you understood Kadane’s algorithm?

yes, i have understood kadane’s algo.

Ok. Then for printing the subarray which has maximum sum, try to understand the working of kadane’s algorithm.


Here is the code. Try to modify it and tell me if you are able to do so. Else I will help you.
We just have to understand that a new subarray starts whenever curr=0. And when maxsum<curr, we get to know about the ending point of the maximum sum subarray.

i still can’t get the track of start of substring.

There you go. Check it and tell me if you are able to understand it -

i got it now. thanks