This problem evaluates skills in interval arithmetic and aggregation for time-based pay computation alongside routing and load-balancing knowledge covering round-robin and consistent hashing with virtual nodes, testing time-interval handling, rate mapping, hashing, and data-structure design for high-volume inputs.
You are given a sequence of delivery-related events for a courier during a day. Your task is to compute the courier’s total pay.
(start_minute, end_minute, rate_per_minute)
where
0 <= start < end <= 1440
.
(pickup_minute, dropoff_minute, per_trip_bonus)
.
Return the total pay for the courier for all trips combined.
0
for that portion.
[start_minute, end_minute)
.
1e5
intervals and
1e5
trips.
Design a small in-memory request router for a set of backend servers.
Implement a router that supports:
addServer(serverId)
removeServer(serverId)
route(requestId) -> serverId
Behavior:
route()
should return servers in round-robin order over the
current
set of servers.
Modify/replace the round-robin approach with consistent hashing so that:
serverId
is a string.
requestId
is a string.
O(log N)
routing time.