Loading
Loading
A podcast network books recording sessions. Each session is a row [start, end] and occupies a studio from start up to, but not including, end. A studio freed at minute t can host a session that starts at minute t.
Return the smallest number of studios that lets every session go ahead as booked.
sessions = [[9, 12], [12, 14], [10, 11], [13, 15]][9,12] → studio Aends: {12}[10,11] → studio BA busy until 12; ends: {11, 12}[12,14] → reuse B (free at 11)ends: {12, 14}[13,15] → reuse A (free at 12)ends: {14, 15} — never more than 22Sign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
| 0 | 0 | 30 |
|---|---|---|
| 1 | 5 | 10 |
| 2 | 15 | 20 |
[5,10] and [15,20] both run during [0,30], but not at the same time as each other.
Example 2
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(n log n) time · O(n) space
Input. Run your code to watch it work on this input, one line at a time.
| 0 | 0 | 30 |
|---|---|---|
| 1 | 5 | 10 |
| 2 | 15 | 20 |
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.
| 0 | 9 | 12 |
|---|
| 1 | 12 | 14 |
|---|
| 2 | 10 | 11 |
|---|
| 3 | 13 | 15 |
|---|
Never more than two sessions are live at once.