DSA Tracker

Topic

Intervals interview questions

All 5 Intervals problems from the curated set, easiest first — a core topic for 6 of the 29 engineering roles.

Easy
1
Medium
4
Hard
0
Sheets
3
Watch the Intervals pattern solved step by step

What Intervals is

Updated 2026-09-09

An interval is a continuous range of numbers defined by two values: a start point and an end point. Think of a calendar event booked from two to four o'clock, or a cut segment on a ruler. Because each interval covers every number between its boundaries, two intervals can sit apart with empty room between them, touch at an edge, or overlap across a shared span of numbers.

When to reach for it

Reach for intervals when the input consists of start and end pairs representing time slots, schedules, ranges, or geometric segments. Phrasings asking to merge overlapping blocks, insert a new meeting into a busy calendar, find the minimum number of conference rooms needed, or count how many intervals must be removed to eliminate overlaps all point directly to interval patterns. Whenever problems involve resource contention over time, think intervals.

How to think about it

The opening move is almost always sorting the intervals by their start times, or occasionally by their end times. Once ordered, compare the current interval with the previous one. If the new start time is less than or equal to the previous end time, the two intervals collide; merge them by stretching the previous end time to the maximum of both ends. If they do not collide, the previous interval is finished, so append it to the result and start tracking the new one. For room counts, split intervals into separate start and end events.

What each operation costs

OperationTime
sort intervals by start or end timeO(n log n)
merge sorted intervals in a single passO(n)
track active meetings using a min-heapO(n log n)
What usually goes wrong
  • Merging two overlapping intervals by taking the second interval end without using the maximum of both ends, which shrinks an interval when the first one completely swallowed the second.
  • Treating intervals that touch at the exact same boundary point as disjoint when the problem statement defines boundaries as closed and inclusive.
  • Forgetting to append the final merged interval to the output list after the iteration loop finishes.

Every Intervals problem, easiest first

Roles that need Intervals

If you are targeting one of these, Intervals sits early in your path rather than being optional.

Track Intervals in your role's order

Pick your target role and all 370 problems resequence to what that interview actually asks. Free.

Start free

Intervals interview questions, answered

How many Intervals problems should I solve for interviews?

5 curated Intervals problems cover the patterns interviews repeat: 1 easy, 4 medium and 0 hard. They are drawn from 3 widely used sheets, deduplicated, and ordered easiest first.

Is Intervals actually asked in coding interviews?

Yes, though how much depends on the role. Intervals is a core topic for 6 of the 29 engineering roles tracked here, including Data Engineer, Security Engineer, Site Reliability Engineer. For other roles it is lower frequency and belongs later in a study plan.

Which Intervals problem should I start with?

Start with Meeting Rooms (Easy). The list on this page is ordered easiest first for that reason, so working top to bottom builds the pattern before the harder variations arrive.

Other topics

Problem set and role mapping as of .