InferenceAI

Enter at least two characters to search.

Start free

Meeting Rooms Needed

mediumGreedy & Intervals25 min25 XP

Each meeting is [start, end); a meeting ending at time tt frees its room for a meeting starting at tt. Return the minimum number of rooms needed.

Examples

EXAMPLE WALKTHROUGHtwo rooms

A guided view of the published example, not a trace of your code.

INPUT[[[0,30],[5,10],[15,20]]]
TASKmeeting_rooms_needed()
EXPECTED OUTPUT2

Start with the input values shown in this example.

Example 1 of 3

Input: meetings = [[0,30],[5,10],[15,20]]

Output: 2

Explanation: two rooms

Input: meetings = [[7,10],[2,4]]

Output: 1

Explanation: one room

Input: meetings = []

Output: 0

Explanation: no meetings

Hint 1

Sort meetings by start; keep a min-heap of end times of rooms in use.

Hint 2

Alternatively sweep over sorted start and end times.

Topics

DSAGreedy & IntervalsPython