A scheduling assistant compares the free time of two people. Each person's free slots are a list of [start, end] ranges (both ends included), sorted by start, with no two slots in the same list overlapping or touching.
Write sharedSlots(mine, theirs) that returns every range of time that is free for both people, sorted by start. A shared moment of zero length, like [5, 5], still counts.
Input: mine = [[0,2],[5,10],[13,23],[24,25]], theirs = [[1,5],[8,12],[15,24],[25,26]] Output: [[1,2],[5,5],[8,10],[15,23],[24,24],[25,25]]
For example [5, 10] and [8, 12] share [8, 10].
Input: mine = [[1,3],[5,9]], theirs = [] Output: []
The second person has no free time.
0 <= mine.length, theirs.length <= 1000000 <= start <= end <= 10^9Run 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 #585 Shared Free Slots of Two Calendars. 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.