You may solve it using depth first search. it will give you all possible
solutions

On Sun, Nov 7, 2010 at 12:11 AM, 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]<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].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to