Rs
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

  1. Sort meetings by start
  1. Min-heap of end times of rooms in use
  1. If earliest end <= start, reuse (pop)
  1. 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.