Intervals
This is a premium interview-preparation course on the **interval** pattern — the family of problems that model each item as a range with a **start** and an **end**, then ask you to merge, count, schedule, or detect overlaps among those ranges. Interviewers love intervals because a single insight unlocks almost the whole category: **sort by start time (or sometimes by end time), then make one left-to-right sweep**. Once the ranges are in order, overlap becomes a local comparison between the current range and the one you are carrying, and greedy choices that look risky turn out to be provably optimal. This course starts with the mechanics — how to represent an interval, when to sort by start versus end, and exactly what overlap means — then works through curated problems grouped by the patterns interviewers actually test: the merge pattern, resource scheduling with a heap, greedy interval selection, and online interval structures such as booking calendars. Every lesson draws the intervals on a number line, dry-runs a concrete input step by step, and shows a clean Java 17 solution.
16
Curated lessons
5
Learning modules
5h 21m
Est. study time
9
Target companies
What you'll learn
- Recognise the interval pattern from phrases like merge, overlap, meeting rooms, or booking.
- Decide whether to sort by start time or end time for a given problem and justify it.
- Sweep sorted intervals in one pass to merge, count overlaps, or schedule resources.
- Design online interval structures (booking calendars, disjoint interval streams).
Your progress
0 / 16
problems completed
16 available now · keep going!
Mark lessons complete as you work through them. Progress is saved on this device and syncs to your account when you sign in.
Learning roadmap
Work top to bottom — each module builds on the last.
- 1
Interval Fundamentals
Sort by start, then sweep left to rightHow to represent an interval, why sorting comes first, exactly what overlap means, and the merge strategy that powers the whole category.
4/4 problems31m - 2
Merge Pattern
Carry one interval; extend on overlap, else emitCombine overlapping ranges into a minimal set of disjoint intervals — the canonical sort-then-sweep problems.
3/3 problems1h 5m - 3
Scheduling Pattern
Sort by start; a min-heap of end times frees resourcesAllocate and reuse resources across overlapping intervals, tracking the earliest free time with a heap.
3/3 problems1h 8m - 4
Greedy Interval Pattern
Sort by end (or start); keep the range that leaves the most roomSelect or cover intervals optimally by sorting on the right key and making a provably correct greedy choice.
3/3 problems1h 7m - 5
Advanced Intervals
Maintain sorted intervals incrementally as queries arriveOnline interval structures: booking calendars that reject conflicts and a stream that coalesces into disjoint intervals.
3/3 problems1h 30m
Modules
5 themed modules from fundamentals to advanced.
Interval Fundamentals
How to represent an interval, why sorting comes first, exactly what overlap means, and the merge strategy that powers the whole category.
Merge Pattern
Combine overlapping ranges into a minimal set of disjoint intervals — the canonical sort-then-sweep problems.
Scheduling Pattern
Allocate and reuse resources across overlapping intervals, tracking the earliest free time with a heap.
Greedy Interval Pattern
Select or cover intervals optimally by sorting on the right key and making a provably correct greedy choice.
Advanced Intervals
Online interval structures: booking calendars that reject conflicts and a stream that coalesces into disjoint intervals.
Full curriculum
12 problems and 4 concept lessons in learning order.
- 1Interval RepresentationInterval Fundamentals Concept
- 2Sorting IntervalsInterval Fundamentals Concept
- 3Overlapping IntervalsInterval Fundamentals Concept
- 4Merge StrategyInterval Fundamentals Concept
- 5Merge IntervalsMerge PatternMedium
- 6Insert IntervalMerge PatternMedium
- 7Non-overlapping IntervalsMerge PatternMedium
- 8Meeting RoomsScheduling PatternEasy
- 9Meeting Rooms IIScheduling PatternMedium
- 10Employee Free TimeScheduling PatternHard
- 11Minimum Number of Arrows to Burst BalloonsGreedy Interval PatternMedium
- 12Remove Covered IntervalsGreedy Interval PatternMedium
- 13Interval List IntersectionsGreedy Interval PatternMedium
- 14My Calendar IAdvanced IntervalsMedium
- 15My Calendar IIAdvanced IntervalsMedium
- 16Data Stream as Disjoint IntervalsAdvanced IntervalsHard