1
var UndergroundSystem = function () {8
* @param {string} stationName12
UndergroundSystem.prototype.checkIn = function (id, stationName, t) {13
this.checkInMap[id] = [stationName, t];18
* @param {string} stationName22
UndergroundSystem.prototype.checkOut = function (id, stationName, t) {23
const [checkInStationName, checkInTime] = this.checkInMap[id];24
const tripKey = `${checkInStationName}-${stationName}`;26
if (!this.tripMap[tripKey]) this.tripMap[tripKey] = [0, 0];28
this.tripMap[tripKey][0] += t - checkInTime;29
this.tripMap[tripKey][1]++;33
* @param {string} startStation34
* @param {string} endStation37
UndergroundSystem.prototype.getAverageTime = function (41
const tripkey = `${startStation}-${endStation}`;42
const [totalTripTime, totalTrips] = this.tripMap[tripkey];43
return totalTripTime / totalTrips;