How do I get the intersection between two arrays as a new array?
- Simple Intersection: Compare each element in
Ato each inB(O(n^2)) - Hash Intersection: Put them into a hash table (
O(n)) - Sorted Intersection: Sort
Aand do an optimized intersection (O(n*log(n)))
All of which are implemented here
https://github.com/juliangruber/go-intersect/blob/master/intersect.go