KatInterview

Minimum Conference Rooms for Scheduled Meetings

Greedy & IntervalsAuto-graded · 19 test cases
MediumAuto-gradedGreedy & Intervalsintervalsheapgreedy

Last updated

Tests greedy interval scheduling with heap-based resource allocation to find the smallest number of rooms needed for overlapping meetings.

You are given a list of meeting time slots, where each slot is represented as a pair [start, end] indicating the start and end times of a meeting. Your task is to determine the smallest number of conference rooms needed to accommodate all meetings without any conflicts.

Two meetings can use the same room if one ends exactly when the other begins. In other words, if a meeting ends at time t and another starts at time t, they do not overlap and can share the same room.

Write a function that takes the list of meeting intervals and returns the minimum number of rooms required.

Constraints:

  • 1 <= len(intervals) <= 10^4
  • intervals[i].length == 2
  • 0 <= start_i < end_i <= 10^6
  • The input intervals may be given in any order

Examples

Example 1

Input: min_conference_rooms([[0, 30], [5, 10], [15, 20]])

Output: 2

Hints

Hint 1

Sort the meetings by their start times to process them chronologically

Hint 2

Track when each occupied room becomes available using a min-heap of end times

Hint 3

When a meeting starts, check if the earliest-ending room is free for reuse