What's the wrong in this code?


#1

int Solution::solve(vector &A, vector &B, vector &C) {
int i= A.size()-1, j= B.size()-1, k= C.size()-1;

int res = INT_MAX;
  
while(i>=0 and j>=0 and k>=0){
    int maxe = max(A[i], max(B[j],C[k]));
    int mine = min(A[i], min(B[j],C[k]));
    res = min(res,maxe - mine);
    if(A[i]== maxe) i--;
    else if(B[j]== maxe) j--;
    else if(C[k]== maxe) k--;
    
}


return res;

}


#2

This works perfectly broo

int Solution::solve(vector &A, vector &B, vector &C) {
int i= A.size()-1, j= B.size()-1, k= C.size()-1;

int res = INT_MAX;

while(i>=0 and j>=0 and k>=0){
    int maxe = max(A[i], max(B[j],C[k]));
    int mine = min(A[i], min(B[j],C[k]));
    res = min(res,maxe - mine);
    if(A[i]== maxe) i--;
    else if(B[j]== maxe) j--;
    else if(C[k]== maxe) k--;

}

return res;
}