Meeting Rooms II

Given meeting time intervals, return the minimum number of conference rooms required.

A way to picture it

You run the office. As each meeting arrives, you glance at the room that frees up soonest. If it's already free, the meeting takes it. If not, every room is busy, so you open a new one.

How to approach it

Sort by start. A min-heap holds each busy room's end time; its top is the next room to free up. Reuse it or add a room.

Example

Input: {"intervals":[[0,30],[5,10],[15,20]]}. Output: 2.

Complexity: O(n log n) time and O(n) space. Sorting, plus a heap operation per meeting.

This page includes an animated walkthrough, Java and Python solutions, and a question to check your understanding.