I would like to know what's the least time consuming algorithm for this.
Given 2 arrays,
aandb, check if any 2 members - one fromaand one frombadd upto a given numberh.
What do you think is the fastest algorithm for this problem? I'm simply looping over both the arrays and trying to find the solution which is very expensive. It's O(mn), I think, where m and n are the lengths of arrays a and b, respectively. Also, it's not necessary that both the arrays have the same length. Do you know any algorithm which is faster than this? For size, consider that the maximum length of both the arrays is about 100000.
Thanks.
P.S. This question isn't a duplicate as it concerns with finding the integers in two different arrays, not one.