Is there any efficient way to get intersection of two slices in Go?
I want to avoid nested for loop like solutionslice1 := []string{\"foo\", \"bar\",\"hello\"}
How do I get the intersection between two arrays as a new array?
A
to each in B
(O(n^2)
)O(n)
)A
and do an optimized intersection (O(n*log(n))
)All of which are implemented here
https://github.com/juliangruber/go-intersect