LC: 759. Employee Free Time - spiralgo/algorithms GitHub Wiki

759. Employee Free Time:

The Essence:

In most of the problems we encountered, there is a solution pattern like abstraction or isolation of given information from all of the unnecessary details.

  • For example, in the case of this problem, we do not need to know which interval belongs to which employee.
  • We just need to know the free duration between successive intervals to find the intersection of them.

Details:

  • In order to adjust the given information according to the succession of intervals, we just need to sort it by start value.
  • We can a built-in Arrays.sort() like function to sort the array.
  • We can use a Priority Queue as Erdem explained quite brilliantly in detail for the corresponding PR: https://github.com/spiralgo/algorithms/pull/354

Here is how we got the result: [5,6],[7,9](/spiralgo/algorithms/wiki/5,6],[7,9)

IMG-1707