Given two unsorted arrays and a value x find such a[i] & b[j] such that (a[i] + b[j] <= x) . and a[i] + b[j] should be as max as possible.
INPUT : X , M , N
input a[ ]
input b[ ]
Example :
10 2 3
3 1
5 2 8
Output :
9
Explaination : we choose 1 from frist array and 8 from second array.
I tried to use binary search for second iteration to make it O(NlogN) and did it is there any other ways to solve it..??
Please if anyone can do comment . Thanks in advance.