Explanation of 1st approach

Could not understand the binary search approach to find the middle element.

Let’s say both the arrays have n elements, so we have total of 2n elements.
Now min denotes the minimum element of these 2n elements and max denotes the maximum of these 2n elements. We know that median of the combined arrays has to be one of these elements , so it must lie in the range min to max.
So we binary search on this range to get the required element.
if we are currently solving for mid, and we find that x elements are smaller than this, now if x<n , we have to shift towards right, and if x>=n, we have to shift towards left, because n elements have to be smaller than median.