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.
// 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);
// 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
[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.intervalsMinimumMeetingRooms([]) returns 0.start < end for every interval, and all times are finite numbers.[start, end) pair.