sort all arrays
for each number in A , A[k]
find two numbers in B and C such that their sum is -A[k]
this can be done in O(n) time:

set i at the beginning of B and j at the end of C
while i<n or j>=0
   if ( B[i] + C[j] == -A[k] ) return true
   if ( B[i] + C[j] < -A[k] ) increase i
   else decrease j

we have to do this for each element of A so the overall complexity is:
O(n2) time O(1) space

correct me if I'm wrong

On 6/15/10, sharad kumar <[email protected]> wrote:
> plzzz comment on this question
>
> --
> 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