Union takes the widest span: [min(starts), max(ends)].
What if you want the narrowest overlap — just the region where both intervals are active?
Flip every min to max and every max to min. That is the entire insight.
[max(starts), min(ends)] — valid when lo <= hi.
Merge and intersection are duals. Once you see it, you never confuse them again.
Two sorted interval lists. Find every region where BOTH have coverage.
Start by checking pairs the naive way — then watch the two-pointer path emerge.
Find all intersections between List A and List B. Tap an interval from A, then one from B to check each pair.
Not every interval in one list has a partner in the other. When there is no intersection, the pointer advancement rule still applies.
Find all intersections between List A and List B. Tap an interval from A, then one from B to check each pair.