Same machine as the string version — one pointer per sequence, both starting at the left,
both only moving right — except the cells are intervals on a shared number line.
The overlap of A[i] and B[j] is always
[max(startA, startB), min(endA, endB)], and it is a real interval only
when that lo ≤ hi. Then comes the only decision in the problem:
retire whichever interval ends first. It is finished — every remaining interval in the
other list starts at or after the one you just compared, so a bar that has already ended can
never meet any of them.
m + n times. The rule to remember: lo = max(starts), hi = min(ends), then advance the pointer whose interval ends first.