Skip to content
BASA DSA

Meeting Rooms II

MediumIntervals

Return the minimum number of rooms needed to hold every meeting. Intervals are half-open [start,end), so a room is reusable at its previous meeting end.

Example 1

Input
intervals = [[1,4],[2,5],[4,7]]
Output
2

Explanation

The first two meetings overlap; the meeting at 4 reuses the room released at 4.

Example 2

Input
intervals = [[0,1],[1,2]]
Output
1

Explanation

A room released at time 1 can host the meeting starting at 1.

Example 3

Input
intervals = []
Output
0

Explanation

No meetings require zero rooms.

Constraints

  • 0 <= number of meetings <= 10000
  • Each interval has start < end

Function contractminMeetingRoomsArguments: json
Loading draft…
SolutionRuns on your device
Loading draft…