How big is the data set? In case the three arrays are quite large, probably they can be divided into smaller sets and then possible combinations can be given to separate threads like {A1,B1,C1}, {A1,B1,C2}...{A1,B2, C1}...where we make BST (one of AVL or RB Tree ) for set C1, C2 etc... and each set is handled in parallel maybe on different processors..may be use mapReduce..
Having said that, i am not sure if the question means such big sets..if no, then probably another optimization is to avoid the same sums like 2+3=5, 3+2=5 or 1+4=5...etc thereby if the search of the third number is once done should not be done again. Again, the question is do we need to do preprocessing to find out various possible non duplicate sums of first two arrays and then search for third in tree/hash table or a plain vanilla N2logN solution is expected. Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Tue, Jan 11, 2011 at 12:04 PM, Decipher <ankurseth...@gmail.com> wrote: > Given three lists: A, B and C of length n each. Write a function which > returns true if any 3 three numbers (1 from each list), sum up to zero. Else > return false, if there is no such combination. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@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 algoge...@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.