Median of Two Sorted Arrays
Mar 28 '11
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
class Solution {
public:
double findMedianSortedArrays(int A[], int m, int B[], int n) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
}
};
本文探讨了两个已排序数组中找到中位数的问题。通过分析不同大小的两个数组A和B, 提出了一个运行复杂度为O(log(m+n))的解决方案。文中提供了一个C++类`Solution`及成员函数`findMedianSortedArrays`的具体框架。
541

被折叠的 条评论
为什么被折叠?



