0PricingLogin
Competitive Programming Academy · Lesson

Line Sweep for Max Overlap

Count concurrent intervals with events.

The Max Overlap Question

How many intervals cover the same moment at once? The peak count is the maximum overlap, the busiest point on your timeline. 📈

Think in Events

Stop thinking about whole intervals. Split each one into two events: a +1 when it starts and a -1 when it ends.

All lessons in this course

  1. Sort Intervals by Start
  2. Merge Overlapping Intervals
  3. Line Sweep for Max Overlap
  4. Minimum Removals for No Overlap
← Back to Competitive Programming Academy