Problems > Segment Overlap > Editorial

Segment Overlap — Solution & Editorial

Back to the Problem

The intersection of [A,B] and [C,D] is [max(A,C), min(B,D)]; its length is clamped at zero.

Complexity: O(1)