Back to problems

Active Couriers Timeline

Algorithm · Uber · Medium

You are given couriers, where each entry couriers[i] = [start, end] describes the period during which courier i is working. The interval includes start but does not include end. Working periods can overlap. Produce a sequence of timeline segments in the form [segmentStart, segmentEnd, activeCount], subject to these rules: activeCount counts the couriers who remain active for the whole segment. Begin a new segment only at a time when the number of active couriers changes.…

Checking your access…