title: Given two arrays a and b .Find all pairs of elements (a1,b1) such that a1 belongs to Array A and b1 belongs to Array B whose sum a1+b1 = k
body: <p>I am looking for the solution of following algorithm with minimal time and space complexity.</p>
  
  <blockquote>
    <p>Given two arrays a and b, find all pairs of elements (a1,b1) such that a1 belongs to Array A and b1 belongs to Array B whose sum a1+b1 = k (any integer).</p>
  </blockquote>
  
  <p>I was able to come up with O(n log n) approach where we will sort one of the array say A and for each of the element b in array B, do binary search on sorted array A for value (K-b) .</p>
  
  <p>Can we improve it any further?</p>