The same technique proposed by Raj + sort PrefixSum array and process it. On 6 ноя, 21:41, Raj <[email protected]> wrote: > Compute PrefixSum Array. > PrefixSum[i]=a[0]+a[1]+a[2]+....+a[i-1]+a[i] > > Now problem reduces to finding two elements having same value. > > For PrefixSum[i], search an element having value PrefixSum[i] in > array PrefixSum from indices 0 to i-1. > Linear search would cost O(n^2), balanced tree O(nlogn), hash O(n).
-- 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.
