I have a possible solution in mind but so as to not muddy the waters with something irrelevant could you give a couple samples what your arrays look like and what you’re considering an intersection? E.g. if A were [3,4,5] and B [23,5,17,42] is the intersection you want [5] ? I think I follow but moar concrete data would help see if I’m on a track in the same neighborhood. . .
Edit: The post below by hv is along the lines I was thinking of actually so maybe not completely irrelevant . . .
The cake is a lie.
The cake is a lie.
The cake is a lie.