Skip to content
Preptima

Intervals interview questions

Merging, overlap detection, and sweep-line scheduling problems.

3 questions in Data Structures & Algorithms.

easy1

easyCoding

Merge a list of overlapping intervals, and justify the key you sorted by

Sorting by start time is what reduces the merge to a single scan carrying one scalar, the end of the open block; sorting by end breaks it, and sorting by end is instead correct for maximum non-overlapping selection. Both run in O(n log n), and equal timestamps decide the answer.

4 minentry, mid, senior

medium2