A video wall has k players. Each scheduled clip is [start, end] in seconds and must play on one player from its start to its end. A player shows one clip at a time; a clip may start on a player at the exact second its previous clip ends.
Write mostClips(clips, k) that returns the largest number of clips that can be fully played. There can be up to 100,000 clips and 100,000 players, so checking every player for every clip is too slow.
Input: clips = [[0,4],[1,3],[2,6],[4,7],[5,8]], k = 2 Output: 4
One player shows [1, 3] then [4, 7]; the other shows [0, 4] then [5, 8]. Any three of the first three clips overlap at time 2, so one of them must be dropped.
Input: clips = [[0,10],[0,10],[0,10]], k = 2 Output: 2
Only two players, and all clips overlap.
0 <= clips.length <= 1000001 <= k <= 1000000 <= start < end <= 10^6Run 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 #580 Most Clips Across k Players. 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.