Skip to content
Decoder

Meeting Rooms II

Medium

Problem

Each meeting is a pair [start, end]. Return the **minimum number of rooms** needed so that every meeting gets a room. A room freed at time 10 can be used by a meeting that starts at 10.

Example 1

Input
[[0, 30], [5, 10], [15, 20]]
Output
2

Example 2

Input
[[7, 10], [2, 4]]
Output
1

Example 3

Input
[[1, 5], [5, 10]]
Output
1
Why
back to back shares a room

Constraints

  • 0 <= intervals.length <= 10^4
  • 0 <= start < end <= 10^6

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.