Line Sweeping Algorithm

Algorithms

  1. Use a counter to keep track when we enter an interval (+1) and when exiting it (-1).
  2. Use prefix sum to find the maximum value (the time when it is the most overlapped).

Reading