I just started studying algorithms and data structures and came across this problem:
Given $x \in \mathbb{N}$ and two integer Arrays $A_1$ and $A_2$ each of the length $n$. Write an algorithm in pseudocode that has a time complexity of $O(n.log(n))$ or better to determine the set $$X = \{ (a,b) | a \in A_1 \land b \in A_2 \land a + b = x \}$$
My idea was to first sort the two arrays, loop through the first array and then perform a binary search through the second one and then, if such a couple (a,b) exists, add the result to a 2D Array(?). But i'm not sure if the time complexity is $O(n.log(n))$ or better.
Thanks in advance!