Back to problems

Car Fleet Scheduler

Algorithm · Waymo · Medium

You are given leases, an array of car lease reservations. Each reservation occupies one car during the half-open time interval [start, end), meaning the car is held from start inclusive up to end exclusive. Assign a car ID to every reservation using these rules: Car IDs are issued sequentially starting at 1. A car can be reused for a reservation that begins at time t only if that car's previous reservation ended at time end and t >= end. If more than one car is free when a…

Checking your access…