Intervals - Miscellaneous / Interval

https://algo.monster/problems/interval_pattern_intro

The usage of β€œx” and β€œy” in the diagram above makes this content difficult to understand, since on a cartesian plane variables named β€œx1” and β€œy1” would typically be paired together.

Given that the algorithm for solving these involves sorting these, using β€œleft” and β€œright” may make this clearer.
This would make the answer to query #1: β€œmax(left1, right1) <= min(left2, right2)”.
Or using β€œa” and β€œb”: β€œmax(a1, b1) <= min(a2, b2)”.

1 Like

is overlap: each end must be greater than the other start.

end2 > start1 && end1 > start2

overlapping part: max of the starts to min of the ends

max(start1, start2) to min(end1, end2)