similar discussion is going on in this thread.. reply to this thread ( mentioned below) , if you dont understand the solution.
http://groups.google.com/group/algogeeks/browse_thread/thread/74fc4fb182a484eb?hl=en On 9/3/12, Puneet Gautam <[email protected]> wrote: > @atul: i didnt get your algo fully.. > Can u just tell me how it works on this array.. {-3 2 1 5 -12 6 1 -2} > the aux array would become {-3 -1 0 5 -7 -1 0 -2} > then whats the next step.? > > We analyze the aux for the repeated element which sets > subarray start= 2 subarray end=6 > > then aux contains 0 at two indices 2 and 6.this gives us the correct answer > here.. > but that wont be the case everytime, right..? > everytime start of subarray cant be 0.. > > Can u clarify more on this..? > Coz i dont think it works on every test array.. > > > > On Sun, Sep 2, 2012 at 12:32 AM, atul anand <[email protected]> > wrote: > >> take aux[] array of same size and store cumulative some at >> aux[i]=sum{input[0 to i]} >> now if you find any repeated element at index i and j then, >> subarray start = i + 1; >> subarray end = j >> >> if array contain 0 at index j then, >> subarray start = 0; >> subarray end = j >> >> >> >> On 9/2/12, Puneet Gautam <[email protected]> wrote: >> > Given an array of positive and negative integers, we need to find the >> > MAX length subarray having sum as ZERO... >> > >> > Is there a solution less than O(n^2)..? >> > >> > Please help .. i m stuck at this problem.. >> > >> > Thanks >> > Puneet >> > >> > -- >> > 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. >> > >> > >> >> -- >> 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. >> >> > > -- > 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. > > -- 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.
