Misc

Overlapping Intervals

Leetcode has a ton of problems about manipulations around intervals, especially merging.

Let's define an interval as [ai,bi][a_i, b_i]. To detect overlapping intervals, we first sort the intervals based on the starting position. Then, two consecutive intervals intersect if a2<b1a_2 < b_1.

|________|
     |________|

where the second interval starts before the first one ends.

Problems

Last updated