Easiest code only 8-10 lines but bad TC


#1

double Solution::findMedianSortedArrays(const vector &A, const vector &B) {
int a = A.size();
int b = B.size();

vector <float> x;
for(int i=0;i<a;i++){
    float p= A[i];
    x.push_back(p);
}
for(int i=a;i < a+b;i++){
    float q = B[i-a];
    x.push_back(q);
}
sort(x.begin(),x.end());
if((a+b)%2 == 0){
    return (x[(a+b)/2]+x[((a+b)/2)-1])/2;
}
else
return x[(a+b)/2];

}