Study Rooms Needed
mediumA library lets student groups book sessions, each [start, end] in minutes. Every concurrently running session needs its own room, and facilities wants the headcount: what is the minimum number of rooms that covers the whole day's sessions?
A session ending exactly when another starts can hand over its room — no extra room needed for that pair.
Example 1
in sessions = [[0, 30], [5, 10], [15, 20]]
out 2
[0, 30] runs throughout; [5, 10] and [15, 20] take turns in a second room.
Example 2
in sessions = [[7, 10], [2, 4]]
out 1
They never coexist — one room suffices.
Constraints
- · 0 <= len(sessions) <= 2000
- · 0 <= start < end <= 10^6
solution.py● loading python…
test results
Hit ▶ Run to test your code against the visible cases.