Maximum Overlap of Intervals

medium · line-sweep, intervals

Maximum Overlap of Intervals

Given a list of inclusive intervals [start, end], return the maximum number of intervals that overlap at any point.

Function signature

func MaxOverlap(intervals [][]int) int

Example

intervals = [[1,3],[2,4],[4,6]]
output = 2

Constraints

  • 0 <= len(intervals) <= 200_000
  • intervals[i] has length 2
  • -1_000_000_000 <= start <= end <= 1_000_000_000

Notes

  • Use a line sweep over event points.
Run tests to see results
No issues detected