sort the array
for each element a[i]
   find two elements that sum to -a[i] (this can be done in O(n) )

the overall time is O(n^2)

On 6/23/10, Raj N <[email protected]> wrote:
> Given a list of n integers?(negative and positive), not sorted and
> duplicates allowed, you have to output the triplets which sum upto 0.
>
> --
> 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.

Reply via email to