intSolution::solve(vector<int> &A, vector<int> &B, vector<int> &C){ int i = 0, j = 0, k = 0, res = INT_MAX; int sa = A.size(), sb = B.size(), sc = C.size(); while(i < A.size() or j < B.size() or k < C.size()) { int a = A[min(i,sa-1)], b = B[min(j,sb-1)], c = C[min(k,sc-1)]; int ma = max({a,b,c}), mi = min({a,b,c}); res = min(res, abs(ma - mi)); if(i < sa and a == mi) i += 1; elseif(j < sb and b == mi) j += 1; elseif(k < sc and c == mi) k += 1; elsebreak; } return res; }