@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 <atul.87fri...@gmail.com> 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 <puneet.nsi...@gmail.com> 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 algogeeks@googlegroups.com. > > To unsubscribe from this group, send email to > > algogeeks+unsubscr...@googlegroups.com. > > 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.