Skip to content

Commit 45a5e1d

Browse files
authored
Update 253-meeting-rooms-ii.js
1 parent 9d69acb commit 45a5e1d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

253-meeting-rooms-ii.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,25 @@ const minMeetingRooms = function(intervals) {
8989

9090
return res
9191
}
92+
93+
// another
94+
95+
/**
96+
* @param {number[][]} intervals
97+
* @return {number}
98+
*/
99+
const minMeetingRooms = function(intervals) {
100+
const hash = {}
101+
for(const [s, e] of intervals) {
102+
hash[s] = (hash[s] || 0) + 1
103+
hash[e] = (hash[e] || 0) - 1
104+
}
105+
let res = 0, cur = 0
106+
const keys = Object.keys(hash).map(e => +e)
107+
keys.sort((a, b) => a - b)
108+
for(const k of keys) {
109+
cur += hash[k]
110+
res = Math.max(res, cur)
111+
}
112+
return res
113+
};

0 commit comments

Comments
 (0)