← 返回 uber 的题目列表Median of Two Sorted Arrays
类型:qbank
Onsite problem-solving prompt equivalent to Median of Two Sorted Arrays. Given two sorted arrays of lengths `m` and `n`, return the median of the combined sorted order in `O(log(m+n))` time.
Requirements
Input: two sorted arrays nums1 and nums2 of lengths m and n.
Return the median value of the combined sorted multiset.
Required time complexity: O(log(m+n)).
Handle both odd and even total lengths.
Notes
Interviewers expect the logarithmic partition solution, not a full merge.
Clarify numeric return type for even-length inputs; most implementations return the average of the two middle values.
Preparation
Re-derive the partition invariant by hand: left side size, right side size, and max-left / min-right checks.
Practice edge cases where one array is empty or all elements of one array sit before the other.