https://oj.leetcode.com/problems/median-of-two-sorted-arrays/
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) {
int *a=new int[m+n];
memcpy(a,A,sizeof(int)*m);
memcpy(a+m,B,sizeof(int)*n);
sort(a,a+n+m);
double median=(double) ((n+m)%2? a[(n+m)/2]:(a[(n+m-1)/2]+a[(n+m)/2])/2.0);
delete a;
return median;
}
};
http://blog.csdn.net/yutianzuijin/article/details/11499917