Author |
Topic: product of two number in a array (Read 1119 times) |
|
witee
Newbie



Posts: 48
|
 |
product of two number in a array
« on: Oct 15th, 2010, 11:05pm » |
Quote Modify
|
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..
|
|
IP Logged |
|
|
|
towr
wu::riddles Moderator Uberpuzzler
    
 Some people are average, some are just mean.
Gender: 
Posts: 13730
|
 |
Re: product of two number in a array
« Reply #1 on: Oct 16th, 2010, 4:12am » |
Quote Modify
|
You could start by filtering out the elements that divide z. And of course a hashtable would make easy work of this problem.
|
|
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
birbal
Full Member
  

Gender: 
Posts: 250
|
 |
Re: product of two number in a array
« Reply #2 on: Oct 25th, 2010, 9:50am » |
Quote Modify
|
Create a hash table from the numbers that divide z. Divide z by a number and check for quotient in the table.
|
|
IP Logged |
The only thing we have to fear is fear itself!
|
|
|
|