From: Ron Jeffries Date: 2002-03-21T04:42:54+09:00 Subject: Re: Why is Ruby so slow? - Solution On Wed, 20 Mar 2002 13:43:19 GMT, nobu.nokada@softhome.net wrote: >> I'm curious. How do you do this operation in O(N+M)? > >Once making a hash whose keys are the minuend's elements, and >remove the subtrahend's elements from it. At last, for all the >minuend's elements, add it to the result array if it is >contained in the hash. Oops, sorry, it was O(2*N+M). Assumes hash lookup is O(N) which it might not be. Close enough for me tho. Thanks! Ronald E Jeffries http://www.XProgramming.com http://www.objectmentor.com I'm giving the best advice I have. You get to decide whether it's true for you.