wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> cs >> product of two number in a array
(Message started by: witee on Oct 15th, 2010, 11:05pm)

Title: product of two number in a array
Post by witee on Oct 15th, 2010, 11:05pm
Given a array of n distinct integer. Find all pairs of x,y
in the array such that z(given) = x * y...do it without sorting and in a most efficient manner..

Title: Re: product of two number in a array
Post by towr on Oct 16th, 2010, 4:12am
You could start by filtering out the elements that divide z. And of course a hashtable would make easy work of this problem.

Title: Re: product of two number in a array
Post by birbal on Oct 25th, 2010, 9:50am
Create a hash table from the numbers that divide z. Divide z by a number and check for quotient in the table.



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board