diff
to store the differential array.book
call with [start, end)
:
diff[start]
by 1 to represent the start of a new event.diff[end]
by 1 to represent the end of the event.cur
to 0 to track the current number of overlapping events.diff
in sorted order, updating cur
with the value of diff[key]
to compute the prefix sum.cur
during the iteration, which represents the maximum k-booking.book
call.