Exit
  1. Learn
  2. Check
  3. Solve
  4. Reflect

Ask when they miss

Two ranges miss each other in only two ways: the first one ends before the second one starts, or the second one ends before the first one starts. Like two meetings, one is finished before the other begins.

If neither happens, they overlap. Turning both "miss" conditions around gives the test directly.

Each starts no later: than the other one ends.
Order doesn't matter: the test works whichever interval comes first.
In code
return a[0] <= b[1] and b[0] <= a[1]
a = [1, 4], b = [3, 6]
123456ab

Does a end before b starts? a ends at 4, b starts at 3. No.

Move 1 of 3

The easy mistakes

Checking only whether the first start lies inside the second range misses the case where the second sits entirely inside the first, such as [1, 10] and [3, 4]. Picture a short meeting wholly inside a long one.

Using "less than" where "at most" is needed wrongly says that touching ranges like [1, 4] and [4, 6] don't overlap.

One inside the other: [1, 10] and [3, 4] overlap even though 1 is not inside [3, 4].
Ends are included: so equal values count as overlapping.