Median of Two Sorted Arrays — C# Coding Problem
Difficulty: hard | Category: binary-search
Problem Description
Given two sorted arrays `nums1` and `nums2`, return the median of the two sorted arrays. The overall run time complexity must be O(log(m + n)). Hint: Binary search on the smaller array. Find a partition such that all elements on the left of the combined arrays are ≤ all elements on the right. The median is the average of the max-left and min-right elements.
Examples
Example 1
Input: nums1 = [1, 3], nums2 = [2]
Output: 2.00000
Explanation: Merged: [1, 2, 3]. Median is 2.
Example 2
Input: nums1 = [1, 2], nums2 = [3, 4]
Output: 2.50000
Explanation: Merged: [1, 2, 3, 4]. Median is (2+3)/2 = 2.5.