A video platform logs each viewing session as [start, end] in whole minutes of the day: the viewer is watching during minutes start to end - 1 (the end minute is not included).
Write peakViewers(sessions) that returns [peak, minute]: the largest number of viewers watching during the same minute, and the earliest minute when that happens. If there are no sessions, return [0, 0].
Input: sessions = [[0,30],[10,40],[20,25],[35,60]] Output: [3,20]
From minute 20 to 24, three sessions overlap. That first happens at minute 20.
Input: sessions = [[5,10],[10,15]] Output: [1,5]
The first session ends just as the second starts, so they never overlap.
0 <= sessions.length <= 10^50 <= start < end <= 1440Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #57 Peak Concurrent Viewers. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.