← Whiteboard questions

Pattern

Intervals

Interval problems are about ranges on a line. Sort by start, then walk once, comparing each range with the last one you kept. Touching and nested ranges are the usual edge cases. The cost is usually O(n log n), from the sort.

Intervals interview questions and solutions