Module 4Priority Queue (BinaryHeap)Lesson 20 of 2322 min
Heap Task: Meeting Rooms / Free Times
Sort intervals + min-heap of end times — classic interview combo.
Meeting rooms II style
- Sort meetings by start
- Min-heap of end times of rooms in use
- If earliest end <= start, reuse (pop)
- Push current end; max heap size = rooms needed
Rust pieces
sort_by_key(|m| m[0])
BinaryHeap<Reverse<i32>>for ends
Challenge
Return true if a person can attend all meetings (no overlaps) — sort only, no heap.
Tips
- Sort + heap combo
- Peek earliest end
- Heap size = rooms
Try it live
Heap Task: Meeting Rooms / Free TimesRust 2021
Loading editor…
Output
Press Run to compile and execute.