d
to keep track of the number of intervals starting and ending at each point.[l, r]
in intervals
.
d[l]
by 1 to mark the start of an interval.d[r + 1]
by 1 to mark the end of an interval.overlaps
to 0 to keep track of the current number of overlapping intervals.res
to 0 to keep track of the maximum number of overlaps.d
by keys (the time points).d
.
overlaps
.res
to be the maximum of itself and overlaps
.res
as the result, which is the minimum number of groups needed.