Binary search to find a partition that splits both arrays into left and right halves.
If total length is m + n, the left half should have (m + n + 1) / 2 elements. If you take i elements from nums1, you need j = (m + n + 1) / 2 - i elements from nums2.
A valid partition satisfies: nums1[i-1] <= nums2[j] and nums2[j-1] <= nums1[i]. This ensures all left elements are smaller than all right elements.
Binary search on the smaller array. If nums1[i-1] > nums2[j], the partition is too far right in nums1. If nums2[j-1] > nums1[i], it's too far left.
Once you find the valid partition, the median is the max of left elements (odd total) or average of max-left and min-right (even total).