Cnbcg hvhkx ghvvb


#1

int Solution::solve(vector &a, vector &b, vector &c) {

int n=a.size();
int m=b.size();
int o=c.size();
int diff=INT_MAX;
for(int i=0;i<n;i++)
{
    int j=0,k=0;  //j for array b , k for array c.
    while(j<m&&k<o)
    {
        //finding difference
        int d=max(a[i],max(b[j],c[k]))-min(a[i],min(b[j],c[k]));
        
        if(d<diff)
        {
            diff=d;
        }
        // increase the indices of whoever is minimum between b[j] and c[k]
        b[j]>c[k]?k++:j++;
        
    }
}
return diff;

}