Back to problems

Garage Occupancy per Timestamp

Algorithm · Waymo · Medium

A parking garage monitors the number of cars inside it across n discrete time steps, numbered 0 through n - 1. You receive a list of tickets, where each ticket [entry, exit] signifies a car entering at time entry and leaving at time exit. The occupancy at each timestamp is determined as follows: A car is considered present beginning at its entry time. A car remains present at its exit time, so the total count does not drop at that moment. The car is removed from the count…

Checking your access…