Quote:
Originally Posted by Tolnaftate2004
Also, the method you proposed for determining the intersection gives duplicates.
|
PHP Code:
temp.intersect = new[smallerarray.size()];
for(e: temp.largerarray)
temp.b.("v"@e) = true;
for(e: smallerarray)
if(temp.b.("v"@e)) {
temp.intersect[temp.j] = e;
temp.b.("v"@e) = false;
temp.j++;
}
I should also point out that its O(n+m)