Back to problems

Design Underground System

Object-Oriented Programming · Bloomberg · Medium

Requirements Create a class that tracks when riders enter and exit stations, then calculates the mean trip duration for any ordered station pair. checkIn(id, station, t) logs rider id arriving at station at timestamp t. Each rider can have no more than one unresolved check-in. checkOut(id, station, t) logs rider id departing from station at timestamp t and completes that rider's corresponding check-in. getAverageTime(start, end) provides the mean duration for every completed…

Checking your access…