I have two arrays, each containing a few thousand
I want to find out if they intersect, but don't care about the intersection itself.
Currently, I do it this way.
func intersects(array1, array2):
var intersect = false
for item in array1:
if item in array2:
intersect = true
I do not feel like this is the most optimal way to do it. In fact, I am experiencing performance issues doing it this way.
What is the fastest way to check arrays for intersection?
I am open to using a different data type, like dictionaries. I am even open to using a different type of object for my elements, for example, using subarrays rather than