Event Overlap Analysis

Algorithm Intervals Scheduling

You are given a list of events where each event is represented by a start time and an end time. The times can be assumed to be integers (for example, representing hours in a day or a timestamp).

Your task is to write a function that calculates the maximum number of events that overlap at any given time point.

Requirements

  • The function should accept a list of events. Each event can be represented as a two-element structure (array, tuple, or object) containing the start and end times.
  • Events that only touch at their boundaries are not considered overlapping. In other words, if one event ends exactly when another begins, they are not overlapping.
  • The solution should correctly handle various cases including:
    • A list with no events
    • A list where all events overlap
    • A list with events that have no overlaps

Example

Suppose you are given events as follows:

events = [
    { "start": 1, "end": 4 },
    { "start": 2, "end": 5 },
    { "start": 7, "end": 9 },
    { "start": 3, "end": 6 }
]

In this example, the maximum number of overlapping events is 3 (during the period when events starting at 1, 2, and 3 are overlapping).

Input / Output

  • Input: A list of events. Each event includes a start and end time.
  • Output: An integer representing the maximum number of overlapping events.

Write your solution in the programming language of your choice and ensure it handles edge cases correctly.


Loading...