Multiple choice technology

I have two 'bin's containing natural numbers (both equal size 'n'), and I am told to take out two numbers, one from each 'bin'. Each time I select the numbers, I find their summation. This process continues till the 'bin's are exhausted. I have to find out whether all such summations can be equal. With what best time complexity can I check whether this is possible or not?

  1. n^n

  2. nlogn

  3. n^2logn

  4. n^2

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

To check if all pair sums can be equal, we need both arrays sorted. If all pair sums S are equal, then the sum of all pairs = n*S = sum(array1) + sum(array2), meaning S must equal the average sum. Sorting both arrays takes O(n log n), then one O(n) pass verifies if corresponding elements give consistent sums.