CodeSpeek

Meeting Rooms II

Medium · Intervals

You are given a list of meeting time intervals, each defined by a start and end time. Determine the minimum number of meeting rooms required so that no two meetings overlap. Two meetings that touch at the exact same time, one ending exactly when another begins, do not need separate rooms.

Examples

Input:  intervals = [[0,30],[5,10],[15,20]]
Output: 2
Why:    The meeting [0,30] overlaps with both [5,10] and [15,20], but those two never overlap each other, so two rooms suffice.
Input:  intervals = [[7,10],[2,4]]
Output: 1
Why:    The two meetings do not overlap in time, so they can share a single room.
Input:  intervals = [[1,5],[5,10],[10,15]]
Output: 1
Why:    Each meeting starts exactly when the previous one ends, so one room is always enough.

Constraints

0 <= intervals.length <= 10^4, 0 <= start_i < end_i <= 10^6

Practise it by voice

Describe the solution out loud and the interviewer writes exactly what you say, asks when you are vague, and runs the tests in your browser.

Practise Meeting Rooms II

This statement is written for CodeSpeek. The problem is part of the NeetCode 150 list; Watch NeetCode's explanation of Meeting Rooms II. Reference solutions from the NeetCode repository (MIT) are used to verify our tests.