Getting runtime error when A is empty and B={20} can someone please help


#1

double Solution::findMedianSortedArrays(const vector &A, const vector &B) {

vector<double> C;
int n1=A.size(),n2=B.size();

int i=0,j=0,k=0;
while(i<n1 && j<n2){
    if(A[i]<B[j])C[k++]=A[i++];
    else C[k++]=B[j++];
}
 while (i < n1){
    C[k++] = A[i++];
 }
while (j < n2){
    C[k++] = B[j++];
}
int n3=C.size();
double ans=0;
if(n3%2==1)return C[(n3-1)/2];
if(n3%2==0){
    ans=C[n3/2]+C[(n3-1)/2];
  
}
  return ans;

}.