Shared Free Slots
Two calendars each list their free slots as closed intervals [start, end], sorted by start time and not overlapping within the same calendar.
Return every interval during which both people are free, sorted by start. A shared single instant such as [5, 5] counts.
Example 1
Input: a = [[1,4],[6,9]], b = [[2,7]] Output: [[2,4],[6,7]]
Example 2
Input: a = [[1,5]], b = [[5,8]] Output: [[5,5]]
Constraints
- 0 <= a.length, b.length <= 10^4
- 0 <= start <= end <= 10^9
Hint 1
Use one pointer per calendar.
Hint 2
After checking the overlap, advance whichever slot ends first.
Good practice for: Frontend Developer, Backend Developer, Full Stack Developer, Mobile App Developer, Automation Test Engineer, Cloud Engineer
Run checks your code on 2 sample tests. Submit runs all 7 tests, including hidden ones, and earns points. Use console.log to debug. Python's first run can take a few seconds while it starts.