There's an O(n) algo for this, ... as you go thru each integer, keep an
accumulated sum.  If this accumulated sum becomes negative, ... reset it to
0.  At each time, compare the accumulated sum with the best sum so far and
update as necessary.

On 8/22/07, Ravi <[EMAIL PROTECTED]> wrote:
>
>
> You're given an array containing both positive and negative integers
> and required to find the subarray with the largest sum.
> Write a routine in C for the above.
>
>
> >
>


-- 
Fear of the LORD is the beginning of knowledge (Proverbs 1:7)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to