wu :: forums
« wu :: forums - product of two number in a array »

Welcome, Guest. Please Login or Register.
May 28th, 2024, 10:27pm

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: towr, william wu, ThudnBlunder, SMQ, Eigenray, Grimbal, Icarus)
   product of two number in a array
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: product of two number in a array  (Read 1076 times)
witee
Newbie
*





   
Email

Posts: 48
product of two number in a array  
« on: Oct 15th, 2010, 11:05pm »
Quote Quote Modify 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: male
Posts: 13730
Re: product of two number in a array  
« Reply #1 on: Oct 16th, 2010, 4:12am »
Quote Quote Modify 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: male
Posts: 250
Re: product of two number in a array  
« Reply #2 on: Oct 25th, 2010, 9:50am »
Quote Quote Modify 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!
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

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