VFlash: Fast, Accurate Visual Planning via Flash Primitive Decoding
u_Unrolled
DSA for AI/ML · Module 14: Greedy and intervals

Lesson 14.6 of 6 in this module Unrolled Pro

Meeting Rooms II

The minimum number of rooms needed so every meeting gets one, which is the maximum number of meetings happening at the same moment. From counting the meetings active at every start time (O(n²)), to sorting by start and keeping the end times of rooms in use in a min-heap, reusing the room that frees up first (O(n log n)), and an equivalent sweep over sorted starts and ends. Then assigning actual rooms, small integer times with a difference array, weighted demand, and peak memory from tensor lifetimes, the calculation behind activation memory planning.

about 10 min 3 Python examples 2 quick checks

Problem. Given meetings [start, end) (a meeting ending at 10 frees its room for one starting at 10), return the minimum number of rooms so that no two meetings in the same room overlap.

text
[[0, 30], [5, 10], [15, 20]]   →   2
[[7, 10], [2, 4]]              →   1
[[1, 5], [5, 8], [2, 6]]       →   2      ([1, 5) and [5, 8) can share a room)

Lesson 14.4 chose which intervals to keep on one machine. Here every meeting must happen, and the question is how many machines. The answer is the largest number of meetings that overlap at any single moment: you need at least that many, and a greedy assignment never needs more.

ML context. Replace meetings with jobs and rooms with GPUs, and this is "how many GPUs does this schedule need?". Weight each interval by its memory and the same sweep computes peak memory: given each tensor's allocation and free step during a training step, the peak of the running sum is the memory the step needs. Activation-memory planners and compilers compute exactly this to decide what to recompute or offload (Change D).


1. Step 1: Clarify

That's the preview. Modules 00–01 are free; this lesson is part of Unrolled Pro.
Staff AI & Pro Tier Lesson

Unlock "Meeting Rooms II"

The foundations are free forever. Unrolled Pro unlocks the complete lesson, production architectures, and 55 battle-tested ML system design case studies.

Everything included with Pro:
All 234+ Deep-Dive Lessons across transformer internals, inference, RAG & agents
55 Staff-Level ML & System Design Case Studies with mathematical capacity estimates
AI Engineer Sheet & Exercises with worked solutions, self-checks, and code
100 Landmark Research Papers guided walkthroughs & progress tracking
14-Day Money-Back Guarantee — 100% full refund if you aren't satisfied
View Plans & Unlock All Lessons

From ₹167/mo (~$2/mo) · Cancel anytime · Instant activation

100% Risk-Free: 14-day no-questions-asked money-back guarantee