aboutsummaryrefslogtreecommitdiff
path: root/design_underground_system.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'design_underground_system.cpp')
-rw-r--r--design_underground_system.cpp20
1 files changed, 0 insertions, 20 deletions
diff --git a/design_underground_system.cpp b/design_underground_system.cpp
deleted file mode 100644
index f0904d2..0000000
--- a/design_underground_system.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-class UndergroundSystem {
-public:
- unordered_map<int, pair<string, int>> checkIns;
- unordered_map<string, pair<int, int>> routes;
- UndergroundSystem() {}
- void checkIn(int id, string stationName, int t) {
- checkIns[id] = {stationName, t};
- }
- void checkOut(int id, string stationName, int t) {
- auto [stn, start] = checkIns[id];
- checkIns.erase(id);
- string route = stn + "," + stationName;
- routes[route].first++;
- routes[route].second += t - start;
- }
- double getAverageTime(string startStation, string endStation) {
- auto &[count, sum] = routes[startStation + "," + endStation];
- return (double)sum / count;
- }
-};