Please point the mistake in this. Gives wrong answer


#1

int solv(vector A, vector B, vector C){
// cout<<“hey”<<endl;
int a = 0;
int b = 0;
int min1 = INT_MAX;
int a1, b1;
int ans = INT_MAX;
while(a<A.size() && b< B.size())
{
int x =abs(A[a]-B[b]);
if(x < min1){
min1 = x;
a1 = A[a];
b1 = B[b];
}

    if(A[a]<B[b])
    {
        a+=1;
    }
    else
    {
        b+=1;
    }
}
for(int i = 0;i<C.size();i++){
    ans = min(ans,abs(max(max(a1,b1),C[i])-min(min(a1,b1),C[i])));
}
return ans;

}

int Solution::solve(vector &A, vector &B, vector &C) {

int x = solv(A,B,C);
int y = solv(B,C,A);
int z = solv(C,A,B);

int sol = min(x,min(y,z));
cout<<x<<" "<<y<<" "<<z<<endl;
return sol;

}