Skip to content

Commit fbcc06d

Browse files
committed
feat(rank): ✨整理 5370
1 parent c9c02d7 commit fbcc06d

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

Rank/182/solution3.js renamed to Rank/182/5370/solution1.js

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,31 @@
1-
1+
/**
2+
* https://leetcode-cn.com/problems/design-underground-system/submissions/
3+
*
4+
* Medium
5+
*
6+
* 5370. 设计地铁系统
7+
*
8+
* 300ms 100.00%
9+
* 59.3mb 100.00%
10+
*/
211
var UndergroundSystem = function() {
3-
this.inMap = new Map();
12+
this.record = new Map();
413
this.resultMap = new Map();
514
};
615

7-
/**
8-
* @param {number} id
9-
* @param {string} stationName
10-
* @param {number} t
11-
* @return {void}
12-
*/
1316
UndergroundSystem.prototype.checkIn = function(id, stationName, t) {
14-
this.inMap.set(id, [stationName, t]);
17+
this.record.set(id, [stationName, t]);
1518
};
1619

17-
/**
18-
* @param {number} id
19-
* @param {string} stationName
20-
* @param {number} t
21-
* @return {void}
22-
*/
2320
UndergroundSystem.prototype.checkOut = function(id, stationName, t) {
24-
const [startStation, startT] = this.inMap.get(id);
21+
const [startStation, startT] = this.record.get(id);
2522
const time = t - startT;
2623
if (!this.resultMap.has(`${startStation}-${stationName}`)) {
2724
this.resultMap.set(`${startStation}-${stationName}`, []);
2825
}
2926
this.resultMap.get(`${startStation}-${stationName}`).push(time);
30-
this.inMap.delete(id);
27+
this.record.delete(id);
3128
};
32-
33-
/**
34-
* @param {string} startStation
35-
* @param {string} endStation
36-
* @return {number}
37-
*/
3829
UndergroundSystem.prototype.getAverageTime = function(startStation, endStation) {
3930
const list = this.resultMap.get(`${startStation}-${endStation}`);
4031
const max = list.length;

0 commit comments

Comments
 (0)