The point here is that any free time interval of the employees is equivalent to some time interval beginning at the end of one employee's time and ending at the other's start, where the start is later the end of the previous interval. We can then just iterate over the intervals sorted by their starting time, and add new free time intervals if the current start is later than the latest end time we have encountered. For recording the latest end time, we would simply need an integer. To iterate over the intervals in such a sorted manner, we can either directly sort it or use a priority queue.
One can also revisit #64 in order to perhaps get a view of this problem from another point.
Resolves: #91
Algorithm:
The point here is that any free time interval of the employees is equivalent to some time interval beginning at the end of one employee's time and ending at the other's start, where the start is later the end of the previous interval. We can then just iterate over the intervals sorted by their starting time, and add new free time intervals if the current start is later than the latest end time we have encountered. For recording the latest end time, we would simply need an integer. To iterate over the intervals in such a sorted manner, we can either directly sort it or use a priority queue.
One can also revisit #64 in order to perhaps get a view of this problem from another point.