In-place sorting would be much faster [ O(N log N) instead of O(N2) ] and can be be written to use O(1) extra memory. However, it destroys the original arrays.
Also, you're wasting memory by placing @c on the stack. You could drop your memory usage from O(N) to O(1) by compressing @c in-place. grep doesn't work in-place like sort when the source and destination is the same.
Update: Added downside.
In reply to Re^2: Difference arrays.
by ikegami
in thread Difference arrays.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |