Why is it important for m <=n


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


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

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.


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.