Can you please make the necessary changes in this code. I am getting segmentation fault


#1

double Solution::findMedianSortedArrays(const vector &A, const vector &B)
{
int m=A.size();
int n=B.size();
if(m>n)
findMedianSortedArrays(B,A);
double ans;
int low=0,high=m;
while(high>=low)
{
int partition_x=(high+low)/2;
int partition_y=(m+n+1)/2-partition_x;

    int maxleftX=(partition_x==0) ? INT_MIN : A[partition_x-1];
    int minrightX=(partition_x==m) ? INT_MAX : A[partition_x];
    
    int maxleftY=(partition_x==0) ? INT_MIN : A[partition_y-1];
    int minrightY=(partition_x==n) ? INT_MAX : A[partition_y];
    
    if(maxleftX<=minrightY && minrightX>=maxleftY)
    {
        if((m+n)%2==0)
            return (double)(max(maxleftX,maxleftY)+min(minrightX,minrightY))/2;
        else
            return (double)max(maxleftX,maxleftY);
    }
    else if(maxleftX>minrightY)
        high=partition_x-1;
    else
        low=partition_x+1;
}

}