Why am I getting a TLE?


#1

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

int i=0, j=0, k=0, m1 = 0, m2 = 0;
while (i<A.size() && j<B.size() && k<C.size())
{
    m1 = min({A[i], B[j], C[k]});
    m2 = max({A[i], B[j], C[k]});
    while(i<A.size())
    {
        m1 = min({A[i], B[j], C[k]});
        while (m1==A[i] && m1<=m2)
        i++;
    }
    
    while(j<B.size())
    {
        m1 = min({A[i], B[j], C[k]});
        while (m1==B[j] && m1<=m2)
        j++;
    }
    
    while(k<C.size())
    {
        m1 = min({A[i], B[j], C[k]});
        while (m1==C[k] && m1<=m2)
        k++;
    }
}
return max({A[i], B[j], C[k]}) - min({A[i], B[j], C[k]});

}


#2

Line 9: if m1 != A[i] then the second while loop never exits. same goes for the other two loops.