Why is it important for m <=n


#1

Why is it important for m <=n in the solution ?


#2

because there can be a case such that answer does not exist in array1.

example
A: 1,2 n=2
B: 5,6,7,8,9 m=5

answer is 6, but if you search for median in A you will never find it.


#3

It is not. You can also enforce appropriate imin and imax such that ā€œjā€ always stays in the bounds of the array.
Here is the code.