Quote:
Originally Posted by Kristi
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.c.("v"@e))) {
temp.intersect[temp.j] = e;
temp.c.("v"@e) = true;
temp.j++;
}
|
Okay, so why the temp.intersect array now? We can just do:
PHP Code:
for(e: smallerarray)
if(temp.b.("v"@e))
temp.c.("v"@e) = true;
temp.intersect = temp.c.getdynamicvarnames();
I think O(getdynamicvarnames) ~ O(temp.intersect[temp.j++] =), at worst. I suppose the only issue here would be getting the size to optimize the set-making and the eventual substrings. Just some thoughts...