http://www.perlmonks.org?node_id=482000


in reply to Algorithm for cancelling common factors between two lists of multiplicands

$i{$_}++ for (@a); $i{$_}-- for (@b); @c=grep { $i{$_} > 0 } keys @a; @d=grep { $i{$_} < 0 } keys @b;
btw, are your sample solution arrays right?