passengerChanges
with a size of 1001 (since locations range from 0 to 1000) to represent the passenger count changes at each location.trips
, increment the value at the pickup location by the number of passengers and decrement the value at the drop-off location.passengerChanges
array, keeping a running total of the current number of passengers in the car.capacity
, return false
.true
.