The Difference Between Arrays[1] snippet is O(n^2), but you could make it much more performant for many data types.
[1] https://github.com/Chalarangelo/30-seconds-of-code#differenc...