class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param weightsA int整型vector
* @param weightsB int整型vector
* @return double浮点型
*/
double findMedianSortedArrays(vector<int>& weightsA, vector<int>& weightsB) {
// write code here
for(auto w:weightsB)
weightsA.emplace_back(w);
sort(weightsA.begin(), weightsA.end());
int len = weightsA.size();
// 偶数个元素
if(len%2==0)
return ((double)weightsA[len/2-1] + (double)weightsA[len/2])/2.0;
return (double)weightsA[len/2];
}
};

京公网安备 11010502036488号