Minimum Meeting Rooms
Updated
Problem statement
You are given an array intervals where intervals[i] = [starti, endi] is the time range of meeting i. The meetings can be listed in any order.
A meeting holds its room from starti up to, but not including, endi. So if one meeting ends at time t and another starts at time t, they can use the same room.
Return the minimum number of rooms needed so that every meeting can take place.
Function
minMeetingRooms(intervals: int[][]) → intExamples
Example 1
intervals = [[0,30],[5,10],[15,20]]return = 2Meeting [0,30] runs the whole time. Meeting [5,10] starts while it is still running, so it needs a second room. Meeting [15,20] starts after [5,10] has ended, so it can use that second room. Two rooms are enough, so the answer is 2.
Example 2
intervals = [[7,10],[2,4]]return = 1Meeting [2,4] ends before meeting [7,10] starts. They never overlap, so one room is enough. The answer is 1.
Example 3
intervals = [[1,5],[5,10],[10,15]]return = 1Each meeting starts at the exact time the previous one ends. A room that is freed at time 5 can be used by a meeting that starts at time 5, and the same at time 10. So all three meetings fit in one room, and the answer is 1.
Constraints
1 <= intervals.length <= 104intervals[i].length == 20 <= starti < endi <= 106
More Sentry interview questions
Similar questions at other companies
- Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREENSnowflake interview questions
- Minimum Workers with Job AssignmentsLyft · ONSITE INTERVIEWLyft interview questions
- Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
- Meeting Rooms IIeBay · PHONE SCREENeBay interview questions
- Meeting Rooms IIAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Minimum Appointment Cancellations with a Required BreakMaven Clinic · PHONE SCREENMaven Clinic interview questions
- Meeting Rooms IIRoblox · PHONE SCREENRoblox interview questions
- Minimum CPUs for Fixed-Duration JobsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Schedule Unit-Time Jobs for the Most ProfitScale AI · PHONE SCREENScale AI interview questions