Fastest Code: checking if interval pairs overlap
Given an unsorted input of many interval pairs (50+), write the fastest algorithm to determine if they do not overlap.
An interval pair is said to overlap if interval x and interval y are overlapping.
Example input 1:
interval x , interval y
10-25, 50-60
10-15, 25-60
Output:
Can be in any true false format.
false (They overlap)
reasoning:
a.x overlaps b.x
a.y overlaps b.y
Example input 2:
10-25, 50-60
20-30, 25-30
Output:
true (they do not overlap)
reasoning:
a.x overlaps b.x
a.y does not overlap b.y
Scoring:
[not sure...]
brute force gives a worst case n^2 runtime