This problem was asked by Google.
Given a set of busy time intervals of two people as in a calendar and a time window, find the free time intervals of both the people so as to arrange a new meeting.
Assume that events are chronologically sorted in a calendar.
Calendar A: [(2,5), (10,14), (19,20), (27,30)]
Calendar B: [(3,5), (12,15), (18,21), (23,24)]
Time window: (1,35)
Output: [(1,2), (5,10), (15,18), (21,23), (24,27), (30,35)]