P is for Practical | |
PerlMonks |
Re: Code requested for array intersection countby sauoq (Abbot) |
on Jun 09, 2003 at 15:43 UTC ( [id://264361]=note: print w/replies, xml ) | Need Help?? |
As you don't care how many times the items are in array 1, I'd use a hash rather than multiple greps. A hash will make it an O(M + N) algorithm, the greps are an O(M x N) solution. Of course, this will use more memory too and you should take that into consideration when choosing which to use.
-sauoq "My two cents aren't worth a dime.";
In Section
Seekers of Perl Wisdom
|
|