Compile Ready
DSA
DSA/Intervals

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%

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. 1

    Interval Fundamentals

    Sort by start, then sweep left to right

    How 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. 2

    Merge Pattern

    Carry one interval; extend on overlap, else emit

    Combine overlapping ranges into a minimal set of disjoint intervals — the canonical sort-then-sweep problems.

    3/3 problems1h 5m
  3. 3

    Scheduling Pattern

    Sort by start; a min-heap of end times frees resources

    Allocate and reuse resources across overlapping intervals, tracking the earliest free time with a heap.

    3/3 problems1h 8m
  4. 4

    Greedy Interval Pattern

    Sort by end (or start); keep the range that leaves the most room

    Select or cover intervals optimally by sorting on the right key and making a provably correct greedy choice.

    3/3 problems1h 7m
  5. 5

    Advanced Intervals

    Maintain sorted intervals incrementally as queries arrive

    Online 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.

Full curriculum

12 problems and 4 concept lessons in learning order.

Techniques you'll master

ArrayBinary Search TreeCalendarComparatorData StreamDesignEndpointsGreedyHeapIntervalsLinear ScanMergeOrdered SetOverlapPrefix SumRepresentationSchedulingSortingSweepSweep LineTemplateTreeMapTwo Pointers