Minimum Meeting Rooms NeededLoading saved progress…

Minimum Meeting Rooms Needed

You run a shared office. People book meetings as time intervals, and two meetings that overlap in time cannot share a room. Given the full list of bookings for the day, you want the smallest number of rooms that lets every meeting happen without any two overlapping meetings landing in the same room. That smallest number is exactly the largest number of meetings that are ever in progress at the same instant.

Signature

// intervals: Array<[start, end]>
//   Each meeting is a pair of numbers. The interval is HALF-OPEN: [start, end)
//   means the meeting occupies time from start up to (but not including) end.
//   So a meeting that ends at t = 10 does NOT conflict with one that starts at t = 10.
// returns: number — the minimum count of rooms needed. Just the count, not an assignment.
function intervalsMinimumMeetingRooms(intervals);

Examples

// Three meetings; the [0,30] meeting overlaps both of the others,
// but [5,10] and [15,20] never overlap each other. Peak concurrency is 2.
intervalsMinimumMeetingRooms([[0, 30], [5, 10], [15, 20]]); // → 2
// Back-to-back meetings, each ending exactly when the next begins.
// Half-open intervals mean none of these conflict — one room handles all three.
intervalsMinimumMeetingRooms([[0, 10], [10, 20], [20, 30]]); // → 1
// All three meetings are live at the same time → three rooms.
intervalsMinimumMeetingRooms([[1, 5], [2, 6], [3, 7]]); // → 3

Notes

  • Intervals are half-open [start, end). A meeting ending at t and another starting at t do NOT overlap — they can share a room. Touching boundaries are not conflicts.
  • The answer is a count, not an assignment. You return how many rooms are needed, not which meeting goes in which room.
  • An empty list needs zero rooms. intervalsMinimumMeetingRooms([]) returns 0.
  • The input is not sorted. Meetings arrive in any order; you may sort as part of your approach.
  • Assume start < end for every interval, and all times are finite numbers.
  • Don't worry about returning the actual room-to-meeting assignment, or meetings that span days — every meeting is a single [start, end) pair.
Loading editor…