ya thanks vaibhav! this is how i solved the program. actually this was asked
in an interview of a company called chronus corp. that person also said the
logic so we just traced few arrays and then found the algorithm!
On 10/17/07, Vaibhav Jain <[EMAIL PROTECTED]> wrote:
>
> int sum(int *arr, int n)
> {
> int i;
> int max,temp_sum;
> max=0;
> temp_sum=0;
> for(i=0;i<n;i++)
> {
>             if(max<temp_sum)
>             max=temp_sum;
>             if(a[i]>temp_sum)
>                temp_sum+=a[i];
>             else{
>                     max=temp_sum;
>                     temp_sum=0;
>                   }
> }
> return max;
> }
>
> Time complexity= O(n)
>
> ##################################################################
>
> On 10/13/07, kannan < [EMAIL PROTECTED]> wrote:
> >
> >
> > hellow!
> >          here is the problem statement.
> > you have to find the subset having the maximum sum in the given array
> > of +ve and -ve numbers.
> > try not to follow brute force method.
> >
> >
> > > >
> >

--~--~---------~--~----~------------~-------~--~----~
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