Ctrl K

Studios for Recording Sessions

Medium
A recording center has received session requests: sessions[i] = [start, end] means the session begins at time start and ends at time end. A studio can host only one session at a time, but if a session ends at time t, another one may start in the same studio at that same moment t. Return the smallest number of studios that lets every session run at its scheduled time.
Example 1
sessions=[[9, 12], [10, 11], [11, 14], [13, 15]] → 2

[9, 12] and [10, 11] run at the same time. [11, 14] takes the studio freed at 11, and [13, 15] the one freed at 12. Two are enough.

Example 2
sessions=[[1, 5], [2, 6], [3, 7]] → 3

At time 3 all three sessions are running, so three studios are needed.

Example 3
sessions=[[4, 8]] → 1
Constraints
  • 1 ≤ len(sessions) ≤ 10⁵
  • 0 ≤ start < end ≤ 10⁶
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsFewest Rooms for the Bookings MediumMost Spare Ranges MediumFlowerbed Beauty on a Budget HardFix the Middle of the Line MediumStick Triples That Form a Triangle Medium
loading Python…
Input
sessions=[[9, 12], [10, 11], [11, 14], [13, 15]]
Expected
2

Run checks the first 3 tests in your browser. Submit checks all 102 tests on the server, hidden ones included.