O(n^2) is trivial. Start from every index, try to check if sum becomes zero or not.
On 17 December 2010 17:33, Wladimir Tavares <[email protected]> wrote: > subarray != subset > Wladimir Araujo Tavares > http://www.si.ufc.br/~wladimir <http://www.si.ufc.br/%7Ewladimir/> > "Fiz uma faculdade! Só não fiz a segunda porque acabaram os tijolos." > > > > > > On Fri, Dec 17, 2010 at 4:31 AM, Aditya Agrawal <[email protected]>wrote: > >> a[]={-3,2,4,-6,-8,10,11} >> create an array with cumulative sum: b[]={-3,-1,3,-3,-11,-1,10}. Now >> identify the maximum index distance same value. in this case distance b/w >> -3,-3 is maximum so subarray would be 2,4,-6,-8,10 >> >> >> >> On Wed, Dec 15, 2010 at 6:23 PM, Soumya Prasad Ukil < >> [email protected]> wrote: >> >>> It's a subset-sum problem, I guess. >>> >>> >>> On 15 December 2010 04:12, parth panchal <[email protected]>wrote: >>> >>>> HI HOW ARE YOU >>>> >>>> >>>> On Tue, Dec 14, 2010 at 7:45 PM, divya <[email protected]>wrote: >>>> >>>>> an array contain +ve and -ve element, find subarray whose sum =0; >>>>> >>>>> Lets take input array as a[]={-3,2,4,-6,-8,10,11} >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Algorithm Geeks" group. >>>>> To post to this group, send email to [email protected]. >>>>> To unsubscribe from this group, send email to >>>>> [email protected]<algogeeks%[email protected]> >>>>> . >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>> >>>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]<algogeeks%[email protected]> >>>> . >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> >>> >>> -- >>> regards, >>> soumya prasad ukil >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]<algogeeks%[email protected]> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<algogeeks%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<algogeeks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- regards, soumya prasad ukil -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
