Check if 2 arrays contain the same element Write a program which will take for input 2 integer arrays and return a truthy value if there exists an element which is present in both of arrays, or a falsy one otherwise. The obvious solution to this problem would be to iterate through each element in the first array and compare it against each element in the second, but here's the catch: Your program must have an algorithmic complexity of at most, in the worst case, O(NlogN), where N is the length of the longer array,

Test cases: 

 {1,2,3,4,-5},{5,7,6,8} -&gt; false
 {},{0}                 -&gt; false
 {},{}                  -&gt; false
 {1,2},{3,3}            -&gt; false
 {3,2,1},{-4,3,5,6}     -&gt; true
 {2,3},{2,2}            -&gt; true


This is code-golf, so the shortest code in bytes wins.
Actually, 1 byte
∩

Try it online!
This is merely the set intersection built-in. The resultant value is the intersection of the two sets - a non-empty list (which is a truthy value) if there is an intersection, and an empty list (which is a falsey value) otherwise.
Complexity
According to the Python Wiki, set intersection has a worst-case time complexity of O(N*M) (where N and M are the lengths of the two sets). However, the time complexity is only that bad when the two sets contain distinct objects that all have the same hash value (for example, {&quot;some string&quot;} &amp; {hash(&quot;some string&quot;)}). Since the set elements are only integers in this case (and no two integers hash to the same value unless they are equal), the actual worst-case complexity is O(min(N, M)) (linear in the length of the smaller of the two sets). The construction of each set is O(N) (linear in the number of elements), so the overall complexity is O(max(N, M)) (the complexity is dominated by the construction of the larger set).