This question evaluates understanding of interval overlap modeling, graph connectivity, and algorithmic efficiency by requiring mapping time intervals to an undirected communication graph and identifying its largest connected component.
You are given n people, where person i works during an inclusive time interval [start_i, end_i].
Define a communication graph:
A work group is any set of people whose induced subgraph is connected (it does not need to be a clique; connectivity through a chain is enough). For example, if A overlaps B and B overlaps C, then {A,B,C} is a valid group even if A does not overlap C.
Task: Return the maximum possible size of such a work group (i.e., the size of the largest connected component in this overlap graph).
Constraints (typical interview setting):
n
up to
2e5
.
start_i <= end_i
.
O(n log n)
.