Meeting Rooms II
2 approaches, code in every language
Problem description
You are given a list of meeting time intervals, each described by a start and an end time. Determine the smallest number of separate rooms required so that no two overlapping meetings ever have to share a room.
A meeting that ends exactly when another begins does not count as an overlap, so those two meetings can safely reuse the same room.
Example 1
Input: intervals = [[0,30],[5,10],[15,20]]
Output: 2
The [0,30] meeting overlaps both of the others, so a second room is needed while it runs.
Example 2
Input: intervals = [[7,10],[2,4]]
Output: 1
The two meetings never overlap, so a single room is enough.
Constraints
1 ≤ intervals.length ≤ 10^40 ≤ start < end ≤ 10^6
Create a free account to see the solution
You get the step-by-step animation, the intuition and clean code in every language. Free, no credit card.
After the pattern
Now solve one you haven't seen.
Peak Charging Bay Demand is our own problem on the technique behind Meeting Rooms II: a new statement, so there's no answer to remember. Write it in your browser and run it against graded tests.
1,194 problems · 15,062 graded tests · free