Opening scenario

You're given a list of intervals like meeting times [start, end]. Merge Intervals (LC 56): combine all overlapping intervals and return the disjoint set. Follow-up you should expect: Meeting Rooms II (LC 253) — return the fewest rooms needed to hold all the meetings. Two meetings that overlap in time need two rooms. A third common twist: given intervals, remove the fewest so the rest are non-overlapping ("non-overlapping intervals").

LC numbers identify LeetCode problems.

The endpoint rules differ between these examples: LC 56 merges closed intervals that touch, while meetings use start < end and may reuse a room at exactly the previous meeting's end. The selection example also allows back-to-back intervals. Which order makes the next interval easy to compare with earlier ones?

Question progression

Q1 — Every interval problem starts the same way. What's the universal first move, and which key?

Question: Merge, count rooms, max non-overlapping — all take the same [start, end] input. Comparing every pair for overlap is O(n²). What single preprocessing step collapses…

In the full tutorial

  • Canonical Template
  • Complexity
  • Pattern Recognition Signals
  • Practice Set
  • Pitfalls
  • Variations
  • Closing: When to Reach for This

Glossary history

Click dotted jargon to save explanations here.