A team calendar shows when nobody on the team is busy. schedules[p] is person p's list of busy blocks [start, end], where a block covers the time from start up to end. Lists can be in any order and blocks of different people overlap freely.
Write teamFreeTime(schedules) that returns every gap of positive length, between the earliest busy start and the latest busy end, when no one is busy. Return the gaps as [start, end] pairs sorted by start. If two busy blocks touch (one ends exactly when another starts), there's no gap between them.
Input: schedules = [[[1,2],[5,6]],[[1,3]],[[4,10]]] Output: [[3,4]]
Someone is busy from 1 to 3 and from 4 to 10, so the team is free from 3 to 4.
Input: schedules = [[[1,3],[6,7]],[[2,4]],[[2,5],[9,12]]] Output: [[5,6],[7,9]]
Busy time merges into [1, 5], [6, 7], and [9, 12].
0 <= schedules.length <= 500 <= schedules[p].length <= 10000 <= start < end <= 10^8Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #586 Team-Wide Free Time. 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.