MediumIntervals · Heap · Sorting

Meeting Rooms II

Given meeting times [(start, end), …], return the minimum number of rooms needed to hold all of them without conflicts. Meetings that only touch, like (0,8) and (8,10), can share a room.

[(0,40),(5,10),(15,20)] → 2[(4,9)] → 1

Try:
CALL
1 / 1

Code

The highlighted line runs next. The pill shows the live values in the running call.

Variables

The data structures the code is building

Number line

Meetings on top; rooms (or rooms in use over time) below

Time and space complexity

n = number of meetings. The highlighted row is the solution being traced.

Keyboard: ← → step, Space play or pause. 0 to 8 meetings as (start,end) pairs with 0 ≤ start < end ≤ 1,000,000.